[CMake] Pass an array type argument to a macro

Eric Noulard eric.noulard at gmail.com
Tue Jul 19 06:32:58 EDT 2011


2011/7/19 Laszlo Papp <lpapp at kde.org>:
> Hi,
>
> Is there a way of passing array arguments to a macro with cmake ?

Did you have a look at:
CMakeParseArguments.cmake

cmake --help-module CMakeParseArguments

This makes it easier to parse KEYWORD arguments.

[...]

> The problem is that when I would like to use the aforementioned macro
> like this:
> UNIT_TESTS(
>    ${CORE_LIBS}# libraries argument
>    core # modulename argument
>    objecttest
> )

Then using the indicated module you may turn your MACRO into
something like:

UNIT_TESTS(
                    LIBRARIES ${CORE_LIBS}
                    MODULENAME core
                    TEST objecttests)
[...]

> The workaround can be that I determine an internal variable that can
> be filled out with the proper content and use that internally inside
> the macro, but I do not consider that nice solution. The best would be
> if we can somehow pass array type arguments to the cmake macro. Is
> that possible ? Does it already somehow work like that ?

Keyword introduced arguments + ParseArgument should work.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list