githubcmakevcpkg

Is it possible to use vcpkg on a github library with no install target?


I'm trying to learn my way around cmake projects for c++ and today I'm working on learning how to use vcpkg. One of the libraries I'm interested in trying is cpp-dotenv but it's not currently in the vcpkg repository.

I found some of the docs over on microsoft to configure a github repo within vcpkg, but their example seems to expect an 'install' target be included in the packages cmake configuration. This particular library does not appear to have one. And since I'm just learning cmake, I don't think I can fork it to add one.

Is it possible in the vcpkg.json and/or portfiles.cmake to instruct it to build and copy the library files without an install target in the projects CMakeLists.txt?

laserpants/dotenv-cpp

(I tried requesting they add it to vcpkg repository or at least add the install target)

request to add vcpkg support


Solution

  • It is far easier to add a cmake install command then it is to manually handle it in the portfile.

    Adding the install command in cmake is as easy to add an install(TARGETS ...) command in cmake (see https://cmake.org/cmake/help/latest/command/install.html#targets)

    However, manually doing it in the portfile requires calling vcpkg_cmake_build() with the correct arguments and build targets as well as manually using the file(COPY|INSTALL ...) command to move the build libraries from the buildtree into the packages dir. As such it is much easier to patch upstream CMake to have an install command then it is to manually deal with the installation.