[FEAT] Add new generator-expression $<LIST>
Generator-expressions are more and more powerful and becomes the primary way to configure many features.
Unfortunately, the genex are, in many aspects, far behind the capabilities of CMake
scripting capabilities. The support of lists is very limited and use a completely different approach than CMake
scripting.
For example, today, it is very complex to construct a list by adding a prefix to each element and taking care of the potential empty list:
$<$<BOOL:$<TARGET_PROPERTY:tgt,INCLUDE_DIRECTORIES>>:-I$<JOIN:$<TARGET_PROPERTY:tgt,INCLUDE_DIRECTORIES>, -I>
So, I think this will be useful to offer a new genex, (e.g. $), for list handling offering same capabilities and syntax similar to the list()
command (similar approach than the $<PATH>
genex):
- Reading
- $<LIST:LENGTH,list>
- $<LIST:GET,list,index,...>
- $<LIST:JOIN,list,glue>
- $<LIST:SUBLIST,list,begin,length>
- Modification
- $<LIST:APPEND,list,element,...>
- $<LIST:PREPEND,list,element,...>
- etc...
With a such new genex, the example can be simply rewritten:
$<LIST:PREPEND,$<TARGET_PROPERTY:tgt,INCLUDE_DIRECTORIES>,-I>
For the implementation, to ensure the full compatibility between list()
command and $<LIST>
genex, a new class cmList
can be introduced capturing all the semantics and operations of CMake
list type. And the command and genex can rely on this class.