I have a CMakeLists.txt that does this:
get_target_property(myloc mytarget LOCATION)
It used to work fine, but CMake 3.0 deprecated using LOCATION
(see https://cmake.org/cmake/help/v3.0/policy/CMP0026.html). So I tried using a generator expression:
set(myloc $<TARGET_FILE:mytarget>)
This seemed like it would work, except that generator expressions are not evaluated everywhere, they only seem to work when setting properties of other targets, and are resolved during the "generation" step, not the earlier "configuration" step. The problem is, I need to know the target location in an install()
rule, something like this (the real use is not strip
but that doesn't matter):
install(CODE "execute_process(COMMAND strip ${myloc})")
This worked fine when using LOCATION
but now that's deprecated and I can't figure out the right way to do this. The root of the problem seems to be that install()
is invoked during the "configuration" step, when the target path is not known.
How can I bridge this gap, and discover the target output path as I used to do, before calling install()
?