INVALID: export(EXPORT <exportSet> ...) does not produce targets file that also sets INTERFACE_INCLUDE_DIRECTORIES
CC: @brad.king, @ben.boeckel, @zackgalbreath
In order to produce <Package>Config.cmake
files for the build tree to be a replacement for the install tree (where the targets in these <Package>Config.cmake
files point to include dirs in the source tree and libs in the build tree), these <Package>Config.cmake
files need to be able to include a <Package>Targets.cmake
file produced by
export(
EXPORT <packageName>
FILE <buildDir>/cmake_packages/<packageName>/<packageName>Targets.cmake
)
that sets IMPORTED library targets that also set the INTERFACE_INCLUDE_DIRECTORIES
property in addition to the IMPORTED_LOCATION_<CONFIG>
.
In the refactoring and extension of TriBITS described in TriBITS #299, TriBITS #63 and in more detail in this google doc, there are uses cases where some packages need to be able to configure and build against pre-prebuilt upstsream packages already sitting in the build tree. For that to work, these <Package>Config.cmake
files in the build tree need to be 100% drop-in replacements for the the <Package>Config.cmake
files in the install tree. To select the pre-built packages from the build tree, you just need to configure the downstream CMake project with:
-DCMAKE_PREFIX_PATH=<buildDir>/cmake_packages
and find_package(<Package>)
will find these <Package>Config.cmake
files in the build tree.
To get around this for now, you can see the hack that I have had to put in for now to one of the this case to make it work at:
When using the install <Package>Config.cmake
files that pull in <Package>Targets.cmake
files generated using install(EXPORT <packageName> ...)
, we don't need to manually handle the include dirs since the IMPORTED targets pulled in set it already.