[CMake] foreach() bug?

Alexandre.Feblot at thomsonreuters.com Alexandre.Feblot at thomsonreuters.com
Thu May 7 04:33:58 EDT 2009


Ok, thanks for the info.
Can I expect this "IN" mode to be delivered in 2.6.5?

Alexandre

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com] 


Alexandre.Feblot at thomsonreuters.com wrote:
> foreach(arg ${list})
[snip]
> The empty element has been discarded by foreach(). Is this the wanted 
> behaviour? If it is, how can I manage empty elements when I need them?

The foreach command never even sees the empty arguments.  By the time
${list} is evaluated the empty elements are gone.  This is for language
consistency.  No one would want

   add_executable(myexe ${srcs})

to try to add "" as a source file if srcs has an empty element.

In CMake HEAD from CVS there is an "IN" mode for foreach that supports
explicitly named lists:

   set(my_list "a;b;;c;d")
   foreach(arg IN LISTS my_list)
     ...
   endforeach()

For now you need to use the list() command.  You can iterate over
a range of the list size with foreach(arg RANGE ...).

-Brad


This email was sent to you by Thomson Reuters, the global news and information company.
Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.




More information about the CMake mailing list