When defining CMake goals, you can create alias targets so that the alias name can be used to refer to a specific object in subsequent commands. For instance,
add_library(foo_lib foo.cpp bar.cpp bat.cpp)
add_library(foo::lib ALIAS foo_lib)
As I understand it, this has the advantage that the name foo_libdoes not appear as the target. However, given this alias name, I would like to set all kinds of properties for them, such as:
set_target_properties(foo::lib PROPERTIES COMPILE_DEFINITIONS ...)
target_include_directories(foo::lib PUBLIC ... PRIVATE ...)
but this is not possible, unfortunately, since CMake Error: set_target_properties cannot be used for the purpose of ALIAS. I don’t understand why this should not be possible, because I would like to determine the name of my lib once and refer to this alias whenever I want to set the target property. Any tips on how to use ALIAS targets “correctly”? What is the purpose of ALIAS goals other than that they don’t appear as Make Objects?
source
share