1

I write a library that is built with Visual Studio (msbuild).

I distribute binaries only of the library via vcpkg (I use a private vcpkg registry. The portfile.cmake for the port simply downloads a zip file of the binaries and headers and places them in the vcpkg install tree).

I have a client that is using CMake.

I can integrate vcpkg (manifest mode) into CMake and find_package() finds vcpkg ports except for mine.

I've arrived at the point that I think I need to distribute either a CMake config (<my-package>-config.cmake) or a CMake find module (Find<my-package>.cmake).

All of the books I've read for CMake seem to assume that you can easily export your CMake targets to create a CMake config. Since I don't build my library with CMake I'm not sure how to get a Targets.cmake.

The documentation I'm reading on CMake find modules begins discussing resolving dependencies using CMakeFindDependencyMacro and find_dependency() but vcpkg also manages dependencies (this was the whole reason I distributed my library via vcpkg).

What's the solution here; CMake config or find module?

How does one write either if the project is not built with CMake?

  • 1
    I'd write Find-module. `find_dependency` is for specifying usage requirements for your library. Vcpkg only acquires dependencies and doesn't add any compiler flags to tell buildsystem that you use these dependencies. – Osyotr Aug 11 '22 at 06:57
  • @Osyotr thank you for validating that. This is the path I've pursued. The last step for me is trying to get the vcpkg_installed paths without using paths of the machine on which the module is built, i.e., building a relocatable module. – Michael Ngarimu Aug 12 '22 at 17:45
  • 1
    Example of a relocatable Find-module from my project: https://gist.github.com/Osyotr/709e71a91a3b277b01b684a0d638e758 – Osyotr Aug 12 '22 at 20:02

0 Answers0