Using the $<INSTALL_INTERFACE:...>
and $<BUILD_INTERFACE:...>
generator expressions I can set target properties to different values depending on whether the target is exported in the current build directory or installed globally. I am writing a custom macro to accompany my CMake package and targets and would like to make the macro behave differently depending on where it is exported (in the build directory) or installed. The macro is contained in a <package>-macros.cmake.in
which is included from my <package>-config.cmake
file and is configured into the build directory using configure_file
and later installed. I tried using the generator expressions in variables set using the configure_file
command, but obviously they are not intended to work that way. I assume my requirement is not that uncommon, how is it usually done using CMake?
CMake variable contents dependent on build/install
997 views Asked by Ron At
1
Just create different
<package>-config.cmake
files forexport()
and forinstall(EXPORT)
. In that files you may have a variable which differentiate them.You may even create both files from the same pattern using
configure_file
command with different CMake environment(variables):<package>-config.cmake.in:
<package>-macros.cmake:
CMakeLists.txt: