COMPILE_DEFINITIONS directory property not propagated to targets?

Hi,

apparently, the COMPILE_DEFINITIONS directory property is not (always) propagated to the targets defined in that directory. Is that on purpose? Do I miss something?

In my situation, there is an add_definitions(-Dsomething) in the toplevel CMakeLists.txt. This is correctly propagated to the COMPILE_DEFINITIONS property of subdirectories: get_directory_property(_defines COMPILE_DEFINITIONS) in a subdirectory yields the expected definition.

However, when asking for get_target_property(_defines ${target} COMPILE_DEFINITIONS) with a ${target} defined in that subdirectory, there is nothing.

Is this again something which can only be addressed via generator expressions?

Kind regards
Ingolf

This is expected. The target, at generation time, looks up its COMPILE_DEFINITIONS and its owning directory’s COMPILE_DEFINITIONS and uses the combination. The genex should be able to see this combination, but I’m not 100% sure (in any case, changing it would likely be a policy or need to be a new genex).

The genex should be able to see this combination

Apparently, it does. Thanks; works with generator expressions. Slowly but surely, I am getting used to them :wink:.

Kind regards
Ingolf