[cmake-developers] Setting includes, defines and other usage requirements with one command
Brad King
brad.king at kitware.com
Fri Feb 8 09:54:34 EST 2013
On 01/31/2013 11:35 AM, Stephen Kelly wrote:
> Brad King wrote:
>> What is the purpose of the else case here?
>>
>> + std::string value = !isGenex ? "$<LINKED:" + lib + ">"
>> + : "$<$<TARGET_DEFINED:" + lib + ">:" +
>> + "$<TARGET_PROPERTY:" + lib +
>> + ",INTERFACE_" + property + ">"
>> + ">";
>>
>> If the input is already a genex isn't the author responsible for
>> making sure it is valid?
>
> Yes, a valid genex for linking. Consider this:
>
> add_library(foo ...)
> add_library(bar ...)
> target_link_libraries(foo $<$<CONFIG:Debug>:bar>)
>
> The genex for the INCLUDE_DIRECTORIES of foo needs to be (excuse the python-
> style concats):
>
> "$<$<TARGET_DEFINED:" + "$<$<CONFIG:Debug>:bar>" + ">:" +
> "$<TARGET_PROPERTY:" + "$<$<CONFIG:Debug>:bar>" +
> ",INTERFACE_" + "INCLUDE_DIRECTORIES" + ">"
> ">"
>
> because the result of the genex could either be "" or "bar".
Currently the code
target_link_libraries(foo $<$<CONFIG:Debug>:not_a_target>)
will put a giant generator expression in the include directories
and compile definitions properties and it will be exported, right?
I do not like this. Since we decided not to use a new target-only
command we need to deal with it somehow though. Can we still use
the $<LINKED:${whole_expression}> approach? I think it should be
possible when processing out $<LINKED:...> expressions to dig
into the contained expression to see if there are any real targets.
Actually such digging might be useful anyway because it would help
diagnose and warn/error when users write something non-sensical
like
tll(foo $<TARGET_PROPERTY:bar,INTERFACE_INCLUDE_DIRECTORIES>)
by hand. One thing that tll does know is that its arguments must
be target names or non-target libraries. Other strings make no
sense.
-Brad
More information about the cmake-developers
mailing list