5

I am trying out vcpkg package manager but I am running in some issues. I have a c++ project that uses cmake and vcpkg and have used vcpkg to install the cache2 package. Now everything works but as soon as I push the project and clone it I can't find how to restore the installed packages.

What I have done is this:

  • installed vcpkg as submodule
  • installed cache2 with vcpkg
  • added cache2 to cmake

Till here everything works fine now when I push and clone the project it goes wrong.

  • git clone --recurse-submodules
  • .\extern\vcpkg\bootstrap-vcpkg.bat
  • vcpkg list

Now nothing appears to be installed and I don't want everyone to install all the packages one by one when they clone. Is there someway to automatically install all packages when cloning?

Rick Nijhuis
  • 444
  • 4
  • 19
  • The build output is not part of the repository. I believe the `vcpkg/.gitignore` file is setup to ignore it. – drescherjm Aug 19 '20 at 20:18
  • ***Is there someway to automatically install all packages when cloning?*** If you put the output into the repository it can be large. My vcpkg folder is over 70GB – drescherjm Aug 19 '20 at 20:19
  • @drescherjm So if users clone your project the have to install all packages separately by hand? That seems cumbersome. Guess I can make a small script to check the installed packages, write them to a json file and install them. Seems strange though that there isn't a solution for something as basic as this. – Rick Nijhuis Aug 19 '20 at 20:30
  • You can try modifying the .gitignore file if it works for your use case. – drescherjm Aug 19 '20 at 20:31
  • @drescherjm I can do that for now but I can see it getting to big, but thanks anyway will try that for now. – Rick Nijhuis Aug 19 '20 at 20:35
  • 1
    ***So if users clone your project the have to install all packages separately by hand?*** You can make your port for your software dependent on a list of packages so that if they vcpkg install yoursoftware it will install the dependent packages as part of the build process. – drescherjm Aug 19 '20 at 20:35
  • https://github.com/microsoft/vcpkg/blob/master/docs/specifications/manifests.md this seems hopefull, I think I will try this although it is still in development – Rick Nijhuis Aug 19 '20 at 20:39
  • 1
    Related to my last comment: [https://stackoverflow.com/questions/61016978/cmake-question-how-do-i-use-vcpkg-to-install-dependencies-automatically](https://stackoverflow.com/questions/61016978/cmake-question-how-do-i-use-vcpkg-to-install-dependencies-automatically) – drescherjm Aug 19 '20 at 20:44
  • That seems also like a decent solution, I think I try both and see what I like most. – Rick Nijhuis Aug 19 '20 at 20:51
  • 1
    I create my own overlay port for the software that I have ported to vcpkg. if you are already using CMake with your software creating a port is probably not too difficult. – drescherjm Aug 19 '20 at 20:55

1 Answers1

7

I have found a decent solution using vcpkg manifests, it is still an experimental feature but I haven't had any issues with it yet. In order to use manifests do the following:

  • At your root folder add a vcpkg.json file with the following contents:
{
  "name": "projectname", // should be lowercase, uppercase will give an error
  "version-string": "0.1.0",
  "dependencies": [ // add here your dependencies you would normally install with vcpkg install [package name]
    "catch2"
  ]
}
  • run: vcpkg install --feature-flags=manifests, this will install all dependencies in the array.

In order to remove packages just remove the dependencies from the list and run the above command.

Rick Nijhuis
  • 444
  • 4
  • 19