[cmake-developers] conditionals in generator expressions (was: Target usage requirements and conventions)

Brad King brad.king at kitware.com
Thu May 17 10:49:31 EDT 2012


On 05/17/2012 10:31 AM, Stephen Kelly wrote:
>> We may not need the "else" part but we still need a strict and extensible
>> syntax to delimit the value in the "..." part above.
> 
> not certain what you have in mind with 'extensible' or if you have any ideas 
> of how it might need to be extended.

The structure so far is

 $<IF(${cond})...>

the ${cond} part we are saying is the CMake language IF expression syntax.
However, after the ')' in the normal language comes other commands with
known syntax.  In the generator expression case the "..." contains a *value*.
I don't think it is so readable though:

 $<IF(${cond})${value}>

Perhaps something like

 $<IF(${cond}) THEN(${value})>

Also, what if ${cond} or ${value} has a '>' in it?  All previous generator
expressions have very limited content inside $<>.  Now we're talking about
arbitrary content.  We need encoding, escaping, etc.  It is a can of worms.

> Yes. My idea is based on the properties with generator expressions not being 
> so convenient to edit at runtime as in the example I gave before, but 
> providing this API to wrap the less convenient 'generator containing a 
> boolean expression' elements.
> 
> But indeed, this alone does not solve the problem of creating a strict 
> enough syntax for storage of the properties.

Let's start with the generator expression part and consider helpers later.

-Brad



More information about the cmake-developers mailing list