I think I have found a bug, or at the very least a vexing behavior. Here’s my minimal example:
cmake_minimum_required(VERSION 3.16) project(example) add_library(example INTERFACE) target_compile_definitions(example INTERFACE $<BUILD_INTERFACE:BUILD> $<INSTALL_INTERFACE:INSTALL>) install(CODE [[ message(STATUS "$<TARGET_PROPERTY:example,INTERFACE_COMPILE_DEFINITIONS>") ]])
$ cmake -S . -B build ... -- Configuring done -- Generating done -- Build files have been written to: /home/alex/test/build $ cmake --build build $ cmake --install build --prefix install -- Install configuration: "" -- BUILD
As you can see,
BUILD is printed rather than
INSTALL. I would understand this for
file(GENERATE), but for
install(CODE), this is rather surprising, since it’s the install command I’m going through.
Is there any way to access the
INSTALL_INTERFACE version of properties in a generator expression? If not, was this a deliberate design decision? I’d like to understand it, if so. Obviously to be changed at this point would require a policy.