On 07/19/11 10:57, Laszlo Papp wrote:
> Hi,
>
> Is there a way of passing array arguments to a macro with cmake ?
>

You can simply pass the arguments "by-name" instead of "by-value" and
then double-dereference them inside your macro ( ${${arg}} ).
The design of your macro determines which of its arguments take values
or names of variables.

macro(testmacro simplearg listarg) #both arguments want variables
    message(STATUS "simplearg: ${${simplearg}}")
    #foreach(listitem IN ITEMS ${${listarg}})
    foreach(listitem IN LISTS ${listarg})
        message(STATUS "listitem: ${listitem}")
    endforeach()
endmacro(testmacro)

set(testlist ONE TWO THREE FOUR)
set(testvar testvalue)
testmacro(testvar testlist)


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to