[cmake-developers] conditionals in generator expressions
Brad King
brad.king at kitware.com
Thu Jun 7 13:44:40 EDT 2012
On 06/07/2012 01:25 PM, Stephen Kelly wrote:
> Although the questions are rhetorical, I'll answer them anyway to clarify
> the intention of the proposal. I'm not trying to push my proposal, but I
> want to make sure it's understood :).
The reason I said they're rhetorical is I'm not interested in spending
further time on the design. The pure-$<> approach can be implemented
in a matter of hours or a couple days.
> Assuming that a copy of relevant state can be created
It can't. The internal implementation isn't clean enough for that.
We can't implement isolated environments in the language without
significant internal changes. This is a showstopper for most of
what you proposed.
>> How do names/variables/functions in the generator_expression body bind?
> They don't. They are local to the generator_expression
To what does BUILD_TESTING bind in your example? It wasn't passed in.
Is the generator expression a closure? (again, rhetorical)
>> I suppose the "exe-getting-linked" can be implied when the
>> expression appears inside the list of link libraries for a target,
>
> Yes. I had assumed this was the only possibility actually. We could simply
> define that to be the way it will work, for simplicity.
Sure. As long as the parser is strict enough we can add more later.
> I'd even define these declarative expressions to only be valid on target
> properties, so that, eg, they can't be used in an include_directories()
> call.
All generation takes place within the context of targets, so this does
not matter. Any value passed to the command in directory-level scope
will only be used later inside a target anyway.
> We'll still need to plan the implementation of it anyway :)
cmGeneratorExpression::Evaluate can be taught to handle everything
pretty easily.
Then more places need to be taught to pass values through instances
of cmGeneratorExpression, such as the INCLUDE_DIRECTORIES property
just before it is used in the generators. Each place that constructs
a cmGeneratorExpression instance must give it enough information to
evaluate all the expressions supported in that context. Documentation
must be updated accordingly, and tests added of course.
-Brad
More information about the cmake-developers
mailing list