[CMake] Question about looping inside a macro.

Steven Truppe workbench at gmx.at
Tue Jun 4 17:14:09 EDT 2019


Hi everyone, like you know i'm relative new the cmake and i'm working my
way through the book and the documentation but there is something that i
don't understand in the docs.

I just want to write a macro that uses as first argument a list and then
iterates over it.

The docs show the example:

macro(_BAR)
   foreach(arg IN LISTS ARGN)
     [...]
   endforeach()
endmacro()

So i wrote this macro:

macro(bsPrintList list)

     foreach(l IN LISTS ARGN)

         message(STATUS "List entry: ${l})

     endforeach()

endmacro()


I tried all sorts of combinations like foreach(l ${list}) etc. but come
to no result =(.


This is a really easy questin so i hope someone can explain to me what
i'm doing wrong here, next part i'm going to learn are functions and how
to handle their arguments...


best regards!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190604/2149ea53/attachment-0001.html>


More information about the CMake mailing list