[CMake] Iterating empty elements in a list

Robert Dailey rcdailey.lists at gmail.com
Tue Aug 6 16:10:34 EDT 2013


Just to be clear, I can't use foreach():

foreach( <var> IN LISTS <list> )

I am doing a "yielded" approach to looping by using list( GET ) and
list( LENGTH ) in combination. So I would need the list() functions to
acknowledge empty elements.

On Tue, Aug 6, 2013 at 3:04 PM, Robert Dailey <rcdailey.lists at gmail.com> wrote:
> I've seen that list(LENGTH) will ignore empty elements in a list. Example:
>
> 1;2;;4;5
>
> Length will be 4 here instead of 5. I was trying to come up with a way
> to modify the list as a string prior to iterating it to give empty
> elements some dummy value, so that the above example would appear as:
>
> 1;2;<empty>;4;5
>
> However, this isn't going to work with string( REGEX REPLACE ) as the
> modifications are not included in the continuation of the regex search
> (I think positive lookbehind is needed here?). Basically this case
> cannot be converted:
>
> ;;;
>
> to:
>
> <empty>;<empty>;<empty>
>
> Anyone know how I can iterate empty elements in a list?


More information about the CMake mailing list