[CMake] Recursively calling a macro: Is this possible in CMake?
James Bigler
jamesbigler at gmail.com
Fri Jan 16 19:23:41 EST 2009
This code seems to produce the correct output with either a macro or a
function prototype.
macro( foo )
list( APPEND my_list "+" )
list( LENGTH my_list length )
if( length LESS ${somevar} )
foo()
endif()
# Add this line in for functions
set( my_list ${my_list} PARENT_SCOPE )
endmacro()
set(somevar 100)
set(my_list "")
foo()
message("my_list = ${my_list}")
My guess is that the code isn't necessarily inlined, but interpreted on the
fly with special rules about variable scope.
James
On Fri, Jan 16, 2009 at 4:39 PM, Robert Dailey <rcdailey at gmail.com> wrote:
> Hi,
>
> Suppose I have a macro that rougly behaves like this:
>
> macro( foo )
> list( APPEND my_list <something> )
> if( <foo's length is less than certain number> )
> foo()
> endif()
> endmacro()
>
> How would this be processed in CMake? Obviously you couldn't inline this
> macro because it's recursive. I need to do something like this to
> recursively iterate target dependencies and append all of their includes to
> a single, flattened list.
>
> Thanks.
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090116/b9f87e80/attachment.htm>
More information about the CMake
mailing list