[cmake-developers] conditionals in generator expressions

Brad King brad.king at kitware.com
Thu Aug 23 09:25:33 EDT 2012


On 08/22/2012 06:12 PM, Stephen Kelly wrote:
>> of linking there are multiple targets involved so we do not know
>> which one the user may mean.
> 
> I think it's something we can just define, is it not?

Some expressions might want the target being linked while others may
want the target in which the expression is specified.  Both are
possible within a single evaluation.  Something like $<LINK_TARGET>
could expand to the name of the target being linked in order to allow
that to be specified as the target to look at.

>> In (5) you need to delay evaluation of generator expressions as
>> long as possible, essentially until the computation of the final
>> link line for a specific target.
> 
> Yes. Only the content of LINK_INTERFACE_LIBRARIES needs to be treated that 
> way though.

For STATIC libraries there is no LINK_INTERFACE_LIBRARIES.  The
the libraries given to target_link_libraries *are* the link interface.

> I think I'll defer it for now and work on making generator expressions work 
> for include directories and compile definitions and looking into creating 
> INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINTIONS. I think most 
> of that is realistic for 2.8.10. I'll try to find the bugs for that stuff in 
> the backlog tomorrow and assign them to me and put them on the roadmap.

Sounds good.

> Finding out what new generator expression conditions are needed might also 
> fit. I'm not certain about the TARGET_PROPERTY_BOOL and 
> TARGET_PROPERTY_STREQUAL. I think it might be better to introduce  
> $<BOOL:...> $<STREQUAL:lhs==rhs> and $<TARGET_PROPERTY:prop> and then be 
> able to use eg:
> 
> $<$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>:Qt::WinMain>
> 
> $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>==EXECUTABLE>:QtFoo>

Now *that* is starting to look like a functional language :)

It is a more general approach, but we need to define the
parsing and evaluation in a better way than it is now.  What
if the referenced $<TARGET_PROPERTY:FOO> has a value containing
"=="?  We need the expression processor to support some kind of
escaping/quoting syntax and lazy evaluation.  The STREQUAL test
needs to be able to parse its arguments "$<TARGET_PROPERTY:TYPE>"
and "EXECUTABLE" first and evaluate them recursively.

-Brad



More information about the cmake-developers mailing list