[CMake] Passing lists to macros

David Cole david.cole at kitware.com
Wed Sep 26 20:36:26 EDT 2007


Try:
test("${L1}")

You are passing multiple arguments to the macro by using ${L1} without
double quotes (because it expands to a list with multiple elements). Using
double quotes makes it all go into the first macro argument...

Alternatively, you could look up the help for MACRO using:
cmake --help-command MACRO

and read up on using ARGN as a list of arguments past the formal macro
arguments...


HTH,
David


On 9/26/07, Neal Meyer <nmeyer at dottedzebra.com> wrote:
>
>
> I've got the following in my CMakeLists.txt
>
> SET( L1 *.h *.hpp *.cpp *.c )
> MESSAGE( STATUS "L1 = ${L1}" )
>
> macro( test L2 )
> MESSAGE( STATUS "L2 = ${L2}" )
> FOREACH( L ${L2} )
>  MESSAGE( STATUS "     L = ${L}" )
>  SET( L_LIST "${L_LIST} stuff/${L}" )
> ENDFOREACH( L )
> MESSAGE( STATUS "L_LIST = ${L_LIST}" )
> endmacro( test )
> test( ${L1} )
>
> I get the following output
>
> -- L1 = *.h;*.hpp;*.cpp;*.c
> -- L2 = *.h
> --      L = *.h
> -- L_LIST =  stuff/*.h
>
> I'm expecting
>
> -- L1 = *.h;*.hpp;*.cpp;*.c
> -- L2 = *.h;*.hpp;*.cpp;*.c
> --      L = *.h
> --      L = *.hpp
> --      L = *.cpp
> --      L = *.c
> --  L_LIST = stuff/*.h stuff/*.hpp stuff/*.cpp stuff/*.c
>
> Can anybody help with this?
>
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070926/6c84dbed/attachment.html


More information about the CMake mailing list