[cmake-developers] $LIST_LENGTH{} syntax (was: Support for list length expression in if()-command?)

Brad King brad.king at kitware.com
Tue Jan 22 07:33:42 EST 2019


On 1/22/19 7:09 AM, Torsten at Robitzki.de wrote:
>> Am 22.01.2019 um 12:42 schrieb Brad King:
>> Rather than a special `if` syntax, perhaps we could introduce an
>> explicit `$LIST_LENGTH{mylist}` syntax.  One would need to experiment
>> to see if modifying the variable expansion parser (under CMP0053 NEW
>> behavior only) to support this would have a significant performance
>> impact.
> 
> What would be a good experiment setup?

Using `cmake -P test.cmake` to run a script that does a lot of
variable evaluations without the proposed syntax, and later with it.

> How about adding the ability to add such function? Like:
> 
> procedure(LIST_LENGTH list)
>   list(LENGTH list length)
>   return(${length})
> endprocedure()

We don't have a syntax for invoking functions with return values.
That's a whole other discussion.

-Brad


More information about the cmake-developers mailing list