[cmake-developers] Setting target properties before the target is defined ?

Stephen Kelly steveire at gmail.com
Wed Apr 24 09:28:13 EDT 2013


Brad King wrote:
>> For makefile generators and xcode it is not possible to use create
>> non-imported targets in a buildsystem. On Windows it doesn't seem to be
>> possible either (the : is mistaken for a drive delimiter). It does
>> currently work with Ninja though, so a policy may be needed if it's a
>> workable solution.
> 
> As part of this you could make the policy validate all target names
> against the genex target name recognition regex.
> 

I'm not certain that's a good idea. The project that hits the non-
recognition does not have any control over the name. If the Qt target is 
called Qt5::Some$Target (or some other char that does not validate), and 
KArchive has it in its LINK_INTERFACE_LIBRARIES, and then a 3rd party has

 add_executable(my_cool_archive_app)
 target_link_libraries(my_cool_archive_app KF5::KArchive)

Then the developer of my_cool_archive_app will get hit with the non-
validation, despite being two degrees of separation from Qt5::Some$Target.

This :: check is only for the case where KArchiveConfig.cmake doesn't use 
find_package(Qt5Core) (it doesn't currently, but it will eventually :)), and 
the developer of my_cool_archive_app doesn't use find_package(Qt5Core) 
either.

Adding a regex validation check would be better done when generating the 
LINK_INTERFACE_LIBRARIES of KArchive maybe, though that's still one step 
away from the actual problem. Maybe additionally it should be checked when 
generating the 

 add_library(KF5::KArchive IMPORTED SHARED)

line. That won't catch any problems where imported targets are externally 
generated (as in Qt), but I think it's a better solution.

Thanks,

Steve.





More information about the cmake-developers mailing list