<br><div class="gmail_quote">On Fri, Jan 16, 2009 at 6:23 PM, James Bigler <span dir="ltr"><<a href="mailto:jamesbigler@gmail.com">jamesbigler@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This code seems to produce the correct output with either a macro or a function prototype.<br><br><span style="font-family: courier new,monospace;">macro( foo )<br> list( APPEND my_list "+" )<br> list( LENGTH my_list length )<br>
if( length LESS ${somevar} )<br> foo()<br> endif()<br> # Add this line in for functions<br> set( my_list ${my_list} PARENT_SCOPE )<br>endmacro()<br><br>set(somevar 100)<br>set(my_list "")<br>foo()<br>message("my_list = ${my_list}")<br>
</span><br style="font-family: courier new,monospace;"><br>My guess is that the code isn't necessarily inlined, but interpreted on the fly with special rules about variable scope.<br><br>James</blockquote></div><br>Well my real code is slightly more complex. When I run it I get
infinite recursion of some sort and I have to forcefully close CMake in
order to stop it. Recursion in CMake isn't entirely intuitive so if
someone could breeze over this code and give me some pointers I'd
really appreciate that.<br>
<br>
<br>
<span style="font-family: courier new,monospace;">macro( add_includes_impl target_name )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> get_target_property( target_dependencies ${target_name} LINK_INTERFACE_LIBRARIES )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> foreach( dep ${target_dependencies} )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if( IS_TARGET ${dep} )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> message( "${dep}" )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> list( APPEND flattened_includes ${dep_includes} )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> add_includes_impl( ${dep} )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> endif()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> endforeach()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">endmacro()</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">macro( add_includes target_name )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> set( flattened_includes )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> add_includes_impl( target_name )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">endmacro()</span><br>