On Tue, Mar 31, 2009 at 2:06 PM, Allen Gooch <span dir="ltr"><<a href="mailto:allen.gooch@gmail.com">allen.gooch@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have the following macro for generation of c++ source from a proprietary IDL language:<br><br>macro (oidl_generate IDL_SOURCES IDL_INCLUDE_DIRS)<br> message (STATUS "IDL Sources: ${IDL_SOURCES}")<br> foreach (idlsrc ${IDL_SOURCES})<br>
get_filename_component (idlsrc_file ${idlsrc} NAME_WE)<br> get_filename_component (idlsrc_path ${idlsrc} PATH)<br> set (outsrc_file ${CMAKE_CURRENT_BINARY_DIR}/${idlsrc_path}/${idlsrc_file}.cpp)<br> set (outsrc_path ${CMAKE_CURRENT_BINARY_DIR}/${idlsrc_path})<br>
set (omegaprotocols_SOURCES ${omegaprotocols_SOURCES} ${outsrc_file})<br> set_source_files_properties ($outsrc_file PROPERTIES OBJECT_DEPENDS ${idlsrc})<br> set (insrc_file ${CMAKE_CURRENT_SOURCE_DIR}/${idlsrc})<br>
make_directory (${outsrc_path})<br> add_custom_command (<br> OUTPUT ${outsrc_file}<br> DEPENDS oidl<br> COMMAND oidl ${insrc_file} -m -dynamic -O ${outsrc_path} ${IDL_INCLUDE_DIRS}<br> )<br> endforeach ()<br>
endmacro ()<br><br>I call the macro from another CMakeLists.txt file:<br><br>include (OidlRules)<br>message (STATUS "IDL Sources from protocols: ${omegaprotocols_IDL_SOURCES}")<br>oidl_generate (${omegaprotocols_IDL_SOURCES} ${omegaprotocols_IDL_INCLUDES})<br>
<br>Inside of my macro, the status message indicates that ${IDL_SOURCES} is not getting expanded to the full list, but is instead giving me the first element of the list I passed in. In my CMakeLists.txt file, before I call the macro, status message indicates that the ${omegaprotocols_IDL_SOURCES} value is the expected full list. Is anything special required when passing lists as arguments to macros?<br>
<br>Many thanks,<br><font color="#888888">-allen<br></font></blockquote><div><br>If you want the list to be passed in as a single argument you need to put quotes around it.<br>
<br>
<span style="font-family: courier new,monospace;">macro(print_args)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> message("${ARGC} passed in")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> message("ARGV0 = ${ARGV0}")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> message("ARGV1 = ${ARGV1}")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> message("ARGV2 = ${ARGV2}")</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;">print_args(a b c)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">print_args(a "b;c")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">set(mylist b c)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">print_args(a ${mylist})</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">print_args(a "${mylist}")</span><br style="font-family: courier new,monospace;">
<br>
<br>
=====================<br>
output:<br>
<span style="font-family: courier new,monospace;">3 passed in</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV0 = a</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV1 = b</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV2 = c</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">2 passed in</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV0 = a</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV1 = b;c</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV2 = </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">3 passed in</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV0 = a</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV1 = b</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV2 = c</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">2 passed in</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV0 = a</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV1 = b;c</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ARGV2 = </span><br style="font-family: courier new,monospace;">
<br>
James<br> </div></div>