GoldPKG simplifies VCPKG and CMake Integration by
- Make VCPKG into the NPM of the C++ World (at least npm install and uninstall :-P)
- Making it easier to integrate CMake and VCPKG Manifests
- Making it easier to install and remove packages from Manifests
- Extend VCPKG with more tighter CMake Integration
You will need
- NodeJS/NPM
- CMake
- A Good C++ Compiler
- Ninja-Build(Not Required but we recommend)
> npm install -g goldpkg
> goldpkg --init Project
This will create a CMake Project with GoldPKG Support
You need - To possess a top level CMakeLists.txt
- An Initialized Git Repository - With a commit - As we will add vcpkg as a submodule for you
Run
goldpkg install
GoldPKG will add .vcpkg submodule etc for you
We will also generate a VCPKG Manifest for you
We will also generate a GoldPKG Configuration for you
Run goldpkg --init Samples
This generates a CMake Project in the Samples Folder
The Code generated is Modular
We provide a Sample Library in Lib Folder
And Application in src
We also provide Unit Tests for Library
Next run goldpkg install
-
goldpkg install pkg-names
Overloadsvcpkg install
Installs the packages provided in Non-Manifest Mode
Adds packages to the manifest
Displays Find and Target to CMake for all packages in Manifest
If--cmake
option is specified with path to CMake Directory, adds Find and Target to all CMakeLists.txt that match the globWill add
# AUTOGEN FIND COMMANDS GENERATED BY goldpkg # AUTOGEN FIND PLEASE DO NOT MODIFY find_path(BOOST_ARRAY_INCLUDE_DIRS "boost/array.hpp") # AUTOGEN FIND LIBRARY WILL LOOK FOR PACKAGES HERE ONLY # AUTOGEN FIND ENDS HERE ... # AUTOGEN TARGET GENERATED BY goldpkg # AUTOGEN TARGET PLEASE DO NOT MODIFY target_include_directories(${PROJECT_NAME} PRIVATE ${BOOST_ARRAY_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} PRIVATE libs::SAMPLE-LIB) # AUTOGEN TARGET LIBRARY WILL LOOK FOR PACKAGES HERE ONLY # AUTOGEN TARGET ENDS HERE
-
goldpkg install
Overloadsvcpkg install
Displays Find and Target to CMake for all packages in Manifest -
goldpkg remove pkg-names
Replacesvcpkg remove
which does not work in Manifest mode
Removes pkg-names from Manifest
DEFAULT:- Removes the package from allCMakeLists.txt
found
If--cmake
option is specified, removes Packages fromCMakeLists
provided in command lineThis option here can be used as a glob also (provide src to remove from all CMakeLists.txt in src directory)
Remove is a goldpkg only operation as VCPKG as of Now does not Support Remove
-
goldpkg update
Updates the vcpkg submodule
Runs bootstrap to rebuildvcpkg
executable
Then runs vcpkg update -
goldpkg --versupgrade
Absent in VCPKG
One of our own commands.
Upgrades the Semver version specified in the manifest (choices: "major
", "premajor
", "minor
", "preminor
", "patch
", "prepatch
", "prerelease
")We use the same library as NPM
-
Rest of the commands
Directly passed tovcpkg
- Install the Dependencies using (
goldpkg install
) - Modify the Code and add libraries to your liking
- Run
cmake -S . -B build -G Ninja
This will generate Ninja-Build files for you
I recommend using Ninja-Build because it's pretty nice - Run
cmake --build build
to build the code cd build
- Run
ctest
to start testing
Option | Definition | Type |
---|---|---|
--version | Show version number | [boolean] |
--help | Show help | [boolean] |
--bootstrap | Bootstrap VCPKG | [array] |
--config-json | Provide Path to Configuration File. By Default, Looks in Current Directory | [string] [default: Current Directory] |
--cmake | Provide Path to CMakeLists.txt . |
[string] |
--vcpkg-json | Provide Path to vcpkg Manifest | [string] [default: Current Directory] |
--vcpkg-root | Provide Path to VCPkg. | [string] [default: Current Directory] |
--save-dev, --dev | Save New Package to Dev Environment | |
--cmake-toolchain | Get the Path to VCPKG ToolChain File | |
--triplet | Set the VCPKG Triplet | [string] |
--versupgrade | Semver updates of Manifest | [choices : "major", premajor", "minor", "preminor", "patch", "prepatch", "prerelease"] |
--init | Name the Directory to Initialize the Project | [string] |
--vcpkg | Pass Commands directly to VCPKG instead of using our Overloads | [array] |
We provide a .goldpkg.json
file by default
{
"Bootstrap": ["-disableMetrics"],
"VCPkg": []
}
Currently supports configuring Bootstrap and VCPKG with additional commands
-
Why do we need another package manager after the 100s we already have?
Spoiler Alert
We don't Let's stop making new package managers and start supporting existing onesOur package extends VCPKG to add support for CMake
VCPKG manages the packages
VCPKG performs the downloads
VCPKG performs the installations All we do is Integrate VCPKG and CMake
- Do I need to add Toolchain File when running CMake?
No. We add the Toolchain to the Root CMake File we provide
No need to configure anything. The Process is Automatic
All you need to do is run at least one command in the Root directory
- Do I need to install something for your Library to Work?
Yes you will need to install Node.JS/NPM.
And then run the Command mentioned above
- Does your App work on Windows & Linux?
You bet it does
- Do you plan to add support for these to VCPKG?
That's the Aim.
See TypeScript allows us to develop the code very quickly
So this is a prototyping model
Based on the responses of the userbase, I will try to add new features
- Do you work for Microsoft? Is this package officially backed by Microsoft or VCPKG Team?
The max I have done is created issues and used VCPKG since 2018
I do not and have not yet had the pleasure of working for them
So no, this package enjoys no official support from VCPKG or Microsoft
- I have ideas to share and features to add. Can I help?
GoldPKG needs you!
It's sort of a meme I realise but there are a lot of features we can add here
And I cannot do it alone
- I just learnt how to use VCPKG. Now I have to learn how to use this. Why?
This is a genuine question.
The thing is though, the way GoldPKG is designed, you do not have to learn a new anything.
GoldPKG overloads VCPKG commands
It uses absolutely the same commands so knowledge of one, transfers to another
-
What do you provide in the Generated Repo?
We provide- Clang-Format file. (To use Clang-Format with Support for globs as Input params install clang-format-ex. Another of my libraries)
- A Sample CMake Project with
- Boost Array
- Catch2 for Unit Testing
- VCPKG Manifest with both installed
- Why were these packages chosen?
- To be honest, I have no idea why I chose Boost-Array
- Catch2 is one of the most popular Unit Tests solutions though
- VCPKG installed as a Submodule
- An NPM Package.json
- You can choose not to use it
- I provided it because I sometimes use
- for Git Hooks
- GitHub Actions for Unit Testing CMake on
- Windows
- Linux
- macOS
- I want to run VCPKG Commands Directly. I don't want to use your overloads
We allow that
Use
> goldpkg --vcpkg <-commands->
-
Why create GoldPKG?
I wanted something like Node_Modules and NPM for C++
However, I found nothing that works well
VCPKG working as submodules was begging to be used as the Node_Modules of the C++ World
Begging I tell you. Begging! -
Can this be used for production?
I am not sure. I don't think it should be used in production till we reach our first major release
Not to put to fine a point on it, you could find it here
We might need a lot of help optimising this repo to make it better for most of our userbase here as well
More comments and to make the CMake less CMake-y and more Tutorial like
(I have not written a lot of CMake code in my life and it shows)
The idea is no..., we are not here to overrwrite your packages We reserve our zones, you reserve yours
Now what if you have your own find_package
commands?
No issues, we stop searching the moment our comment at the top is not found
We reserve our zones.
We do not focus on the rest
Right below project()
command
project (SAMPLE-RUN)
# AUTOGEN FIND COMMANDS GENERATED BY goldpkg
We add these at the very end
At the last line
target_link_libraries(${PROJECT_NAME} PRIVATE Catch2::Catch2)
# AUTOGEN TARGET LIBRARY WILL LOOK FOR PACKAGES HERE ONLY
# AUTOGEN TARGET ENDS HERE
We add this either to the first line or after cmake_minimum_required
And only in the Top Level Directory (same as one with VCPKG Manifest)
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
# AUTOGEN TOOLCHAIN Generated by goldpkg
# AUTOGEN TOOLCHAIN Links to LOCAL VCPKG ToolChain File
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/.vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file")
# AUTOGEN TOOLCHAIN Generation ENDS
You work with the deficiencies of VCPKG
VCPKG install in Manifest mode does not showcase CMake Information
So we run vcpkg install package-names
in Non-Manifest Mode first
Get the package-names CMake Information
And append those to the CMake Files
While removing, we do the same Except we delete this time
-
One of my favourite parts of NPM is that using NPM version <-option->
- It not only updates the version like GoldPKG
- But creates a Commit
- And a Tag
- We could add that
-
Nicer Template Repo
- If you have seen our template, it must be
- Painfully obvious that I am not Mr CMake
- Painfully obvious I don't use CMake for a living
- Painfully obvious the Unit Tests to everything are Zero Effort
- If we could clean that up, it would be rather nice!
- Something similar to NPM PUBLISH
- Automatically commit the code and create a Pull Request in VCPKG Repo Manually
- This could be used via GitHub Actions or other such tools
- Or, we modify GoldPKG
- Something simplar to NPM Scripts
- In NPM you can
- Provide script command where
- You can mention the commands you can run
- Say something like
- goldpkg run format
- Would format your entire Codebase
You can contact me via LinkedIn or create a GitHub Issue