[CMake] LIST bugs for cmake version 2.6-patch 0 RC-8

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed May 7 16:31:06 EDT 2008


On 2008-05-07 14:45-0400 Bill Hoffman wrote:

> We actually talked about this when I created policy CMP0007.   Brad had this 
> to say:
>
>
> The foreach command does see empty items:
>
>  foreach(x "" "" a "" b)
>
> will give x each value including the empty string.
>
> However,
>
>  set(ITEMS "" "" a "" b)
>  foreach(x ${ITEMS})
>
> will skip empty ones.  Variable expansion without quotes has *always*
> removed empty items.  It occurs before the foreach command even sees
> them and is consistent across all commands.  We should not change this.

I don't agree.  For consistency sake with the new CMP0007 policy I think you
should expand out the empty elements in LIST variables so the two foreach
commands above give consistent results.  The current inconsistent results
between explicit lists (as in the first foreach command above) as opposed to
an expanded LIST variable which contains the same empty and non-empty
elements (as in the second foreach above) are just confusing.  So I hope you
reconsider this decision.

>
> The difference is that the list command deals with lists by their
> variable name, not in expanded form.  The way to deal with this in
> foreach is to create a new "list" mode that takes a list by name.  So,
> something like
>
>  foreach(x IN ITEMS)
>
> will iterate over the entries of the list contained in the variable
> ITEMS, including empty ones.  This does not require a policy.  It just
> means people cannot iterate through argument lists whose first entry is
> "IN" (already the case for "RANGE").

The case for this variation on the foreach signature is compelling if you
do not expand LIST variables consistently with the equivalent explicit lists.
However, I hope you do expand LIST variables consistently making this
signature unnecessary.

>
>
> BTW, I have fixed the list(SORT to handle empty correctly.
>

Thanks!

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list