[CMake] foreach et lists

Michael Wild themiwi at gmail.com
Wed Jun 22 10:17:24 EDT 2011


On 06/22/2011 04:11 PM, Maxime Lecourt wrote:
> Hello,
> 
> I'm using CMake to do some OCaml building.
> 
> I launch the build command, using add_custom_command, so for the build
> to actually trigger, I added the add_custom_target command.
> 
> Which I thought I did fine :
> 
> MACRO(OCAML_OPT LIST_OF_FILES)
>     message(STATUS ${LIST_OF_FILES})
>     FOREACH(FILE IN LISTS ${LIST_OF_FILES})

      foreach(F IN LISTS LIST_OF_FILES)

i.e. you pass the *name* of the list, not the elements. Otherwise, use
the old syntax

      foreach(F ${LIST_OF_FILES})

Also, try not to use built-in variables or command names for your own
variable names.


Michael


More information about the CMake mailing list