The code for this recipe is available at https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-03/recipe-09 and has a C example. The recipe is valid with CMake version 3.6 (and higher) and has been tested on GNU/Linux, macOS, and Windows (using MSYS Makefiles). In https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-03/recipe-09, we also provide an example compatible with CMake 3.5.
We have so far discussed two ways of detecting external dependencies:
- Using find-modules shipped with CMake. This is generally reliable and well tested. However, not all packages have a find-module in the official release of CMake.
- Using <package>Config.cmake, <package>ConfigVersion.cmake, and <package>Targets.cmake files provided by the package vendor and installed alongside the package itself in standard locations...