The package now has an option EXPORT_BUILD_DIR which exports the build directory to the CMake package registry. This means that find_package() calls in consuming projects can find the package in its build directory. It is useful when working on both the library and consuming projects at the same time as it obviates the need to run make install after every change to the library.
bustache depends on Boost in public header files. CMake target dependencies are transitive, so a target linking to "bustache" inherits the Boost dependency; however, CMake package dependencies are not automatically transitive. The "bustache-config.cmake" previously generated by install() defines an imported target "bustache" and links it to the target "Boost", but it does not call find_package(Boost REQUIRED). This forces consumers of bustache to put this find_package(Boost REQUIRED) call in their own projects before finding bustache, which is obviously undesirable. To avoid this, the package now installs the export (= set of targets) to "bustache-targets.cmake" and generates a separate "bustache-config.cmake" file from the template "bustache-config.cmake.in" which first calls find_dependency(Boost REQUIRED) and then includes "bustache-targets.cmake". This is the recommended approach for handling transitive package dependencies.
The package no also generates and installs a "bustache-config-version.cmake" file which enforces semantic versioning (SameMajorVersion) during package lookup. This has the advantage that it allows installed packages and exported build directories to coexist. Example:
The user installs bustache (current version 4.2.0) with the package manager of her choice (e.g. vcpkg).
The user needs to add a feature to bustache. To do this, she forks and clones the repository and builds it with EXPORT_BUILD_DIR set to ON. However, because find_package() looks for installed packages first, the exported build directory is not found by consuming projects.
After adding the feature, the user increments the minor version number in the local bustache clone (which is now 4.3.0).
In the consuming project, the user refers to the incremented minor version number with find_package(bustache 4.3 REQUIRED). Because of the versioning logic in "bustache-config-version.cmake", CMake will skip the installed version of bustache and find the exported build directory.
Would you be interested in merging these changes into your repository?
In my fork I made some changes to improve the CMake package integration:
https://github.com/jamboree/bustache/compare/master...mbeutel:b917d54
The package now has an option
EXPORT_BUILD_DIR
which exports the build directory to the CMake package registry. This means thatfind_package()
calls in consuming projects can find the package in its build directory. It is useful when working on both the library and consuming projects at the same time as it obviates the need to runmake install
after every change to the library.bustache depends on Boost in public header files. CMake target dependencies are transitive, so a target linking to "bustache" inherits the Boost dependency; however, CMake package dependencies are not automatically transitive. The "bustache-config.cmake" previously generated by
install()
defines an imported target "bustache" and links it to the target "Boost", but it does not callfind_package(Boost REQUIRED)
. This forces consumers of bustache to put thisfind_package(Boost REQUIRED)
call in their own projects before finding bustache, which is obviously undesirable. To avoid this, the package now installs the export (= set of targets) to "bustache-targets.cmake" and generates a separate "bustache-config.cmake" file from the template "bustache-config.cmake.in" which first callsfind_dependency(Boost REQUIRED)
and then includes "bustache-targets.cmake". This is the recommended approach for handling transitive package dependencies.The package no also generates and installs a "bustache-config-version.cmake" file which enforces semantic versioning (
SameMajorVersion
) during package lookup. This has the advantage that it allows installed packages and exported build directories to coexist. Example:EXPORT_BUILD_DIR
set toON
. However, becausefind_package()
looks for installed packages first, the exported build directory is not found by consuming projects.find_package(bustache 4.3 REQUIRED)
. Because of the versioning logic in "bustache-config-version.cmake", CMake will skip the installed version of bustache and find the exported build directory.Would you be interested in merging these changes into your repository?