[cmake-developers] Issues with generator expressions and lists

Brad King brad.king at kitware.com
Wed Feb 27 13:24:28 EST 2013


On 02/27/2013 10:44 AM, Stephen Kelly wrote:
> If I write code like this:
> 
>  add_custom_command(... COMMAND moc -I$<JOIN:-I,foo;bar;bat> ...)
> 
> and hoping to get 
> 
>  moc -Ifoo -Ibar -Ibat
> 
> what I actually get currently is 
> 
>  moc "-Ifoo -Ibar -Ibat"
> 
> That is, one argument instead of three, which makes a difference. 

The idea of your first two commits is good but we need to go
about it a bit differently.

The argument splitting rule should remain simple: a quoted
argument is one value and an unquoted argument expands on ";".
What your topic needs to do is delay the expansion for unquoted
generator expressions from configure to generate time.

The problem is that by the time the arguments get to the
add_custom_command implementation all you have is a string and
no information about the original argument delimiter (unquoted
or quoted).  If we were to refactor command invocation internals
then we could pass the information along.  This would be useful
elsewhere for example to teach the if() command not to auto-deref
variables whose names are inside quoted args (with a policy).

-Brad



More information about the cmake-developers mailing list