[CMake] Passing a var to a macro

Leopold Palomo Avellaneda leo at alaxarxa.net
Sun Mar 30 15:07:47 EDT 2008


A Diumenge 30 Març 2008, Adiel Mittmann va escriure:
> Hi!
>
> On Sun, Mar 30, 2008 at 08:13:27PM +0200, Leopold Palomo Avellaneda wrote:
> > but if I do:
> >
> > file(GLOB plugin_STR  *.c *.cpp *.cxx *.h *.hpp)
> > PRINT_VALUES(${plugin_STR})
> >
> > where:
> >
> > macro(PRINT_VALUES  list)
> > 	message (STATUS "Files to process in the macro PRINT_VALUES ${list}")
> > endmacro(CREATE_FILE_LIST)
>
> A minor correction here: it should be endmacro(PRINT_VALUES).

:-)

> > then I get _only_  the first value of the list.
>
> This is because each item of the list stored in your variable plugin_STR
> gets assigned to a different argument in your macro. This should fix it:
>
> macro(PRINT_VALUES  list)
>   FOREACH(arg ${ARGV})
>     message("File: ${arg}")
>   ENDFOREACH(arg ${ARGV})
> endmacro(PRINT_VALUES)
>
> > Or, what do I have to do to pass a list of values in a macro?
>
> You could do that by specifying the variable NAME instead of its VALUE:
>
> macro(PRINT_VALUES  list)
>   message (STATUS "Files to process in the macro PRINT_VALUES ${${list}}")
> endmacro(PRINT_VALUES)
>
> file(GLOB plugin_STR  *.c *.cpp *.cxx *.h *.hpp)
> PRINT_VALUES(plugin_STR)

really,

thanks a lot.

Best regards,

Leo

-- 
--
Linux User 152692
PGP: 0xF944807E
Catalonia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080330/379d4139/attachment.pgp>


More information about the CMake mailing list