Are generator expressions supported in set_target_properties / IMPORTED_LOCATION

Wondering if this is supported, or I’m doing something wrong.

I have a line that works:

set_target_properties(NSPR::NSPR PROPERTIES
    IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/darwin_arm64/libnspr4.a"
)

But then breaks when I put in a generator expression (simplifying the internals to BOOL/ON for now):

set_target_properties(NSPR::NSPR PROPERTIES
    IMPORTED_LOCATION "$<$<BOOL:ON>:${CMAKE_CURRENT_SOURCE_DIR}/lib/darwin_arm64/libnspr4.a>"
)

The error that comes up makes me think that the generator expression is unsupported, and is just being directly put into the final compiler command:

ninja: error: '$<$<BOOL:ON>:/Users/chrisapple/code/spatial/tps/nspr/nspr/lib/darwin_arm64/libnspr4.a>', needed by 'bin/quaterniontest', missing and no known rule to make it

A related issue Does the IMPORTED_LOCATION property support generator expressions?

never answered the core question.

nor did Generator expressions for IMPORTED_IMPLIB/LOCATION properties? - #2 by marc.chevrier

Which maybe implies I’m just messing something up? :slightly_smiling_face:

In general, generator expressions are only supported in contexts which explicitly list their support (such as the COMPILE_OPTIONS property). IMPORTED_LOCATION does not list such support, so unless some other documentation clearly says otherwise, it can be assumed it does not support them.

1 Like

Perfect! Thank you!