<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 9, 2013 at 7:44 PM, Johannes Zarl <span dir="ltr">&lt;<a href="mailto:johannes.zarl@jku.at" target="_blank">johannes.zarl@jku.at</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I guess you search for something like this:<br>
<br>
function(info)<br>
    set(msg)<br>
    foreach(i RANGE ${ARGC})<br>
        set(msg &quot;${msg}${ARGV${i}}&quot;)<br>
    endforeach()<br>
    message(STATUS &quot;[info] ${msg}&quot;)<br>
endfunction()<br>
<br>
message(&quot;Foo:bar;baz space&quot; &quot;FOO&quot;)<br>
info(&quot;Foo:bar;baz space&quot; &quot;FOO&quot;)<br>
message(two words)<br>
info(two words)<br>
<br>
...which yields the following output:<br>
<br>
Foo:bar;baz spaceFOO<br>
-- [info] Foo:bar;baz spaceFOO<br>
twowords<br>
-- [info] twowords<br>
<br>
The &quot;IN LISTS&quot; signature of foreach seems to do additional list splitting,<br>
leading to (&quot;foo;bar&quot; &quot;baz&quot;) appearing as 3 elements. Accessing the ARGV array<br>
by the positional indices (e.g. ${ARGV0}) prevents the splitting.<br></blockquote><div><br></div><div>This works. Thank you so much.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<br>
HTH,<br>
  Johannes<br>
<div><div><br>
On Wednesday, 9. October 2013, 05:33:26, Clark WANG wrote:<br>
&gt; On Sat, Oct 5, 2013 at 1:38 AM, Matthew Woehlke<br>
&gt; &lt;<a href="mailto:matthew.woehlke@kitware.com" target="_blank">matthew.woehlke@kitware.com</a><br>
&gt;<br>
&gt; &gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; On 2013-09-27 04:18, Clark WANG wrote:<br>
&gt; &gt;&gt; I&#39;m trying to write some MESSAGE() wrappers like info(), warning(),<br>
&gt; &gt;&gt; fatal(), etc which may be a bit easier to use. But I failed to simulate<br>
&gt; &gt;&gt; the<br>
&gt; &gt;&gt; correct MESSAGE() behavior no matter I use MACRO or FUNCTION. For<br>
&gt; &gt;&gt; example: [snip]<br>
&gt; &gt;<br>
&gt; &gt; FUNCTION vs MACRO shouldn&#39;t make a difference in argument parsing AFAIK.<br>
&gt; &gt; The difference is primarily that FUNCTION creates a scope, while MACRO<br>
&gt; &gt; operates in the scope from which it is called.<br>
&gt; &gt;<br>
&gt; &gt; The behavior of MESSAGE seems to concatenate multiple arguments with no<br>
&gt; &gt; separators. So maybe you could do something like:<br>
&gt; &gt;<br>
&gt; &gt; set(msg &quot;&quot;)<br>
&gt; &gt; foreach(part IN LISTS ARGN)<br>
&gt; &gt;<br>
&gt; &gt;   set(msg &quot;${msg}{$part}&quot;)<br>
&gt; &gt;<br>
&gt; &gt; endforeach()<br>
&gt; &gt; # ...do stuff with ${msg}<br>
&gt;<br>
&gt; This does not work either. For example:<br>
&gt;<br>
&gt; $ cat CMakeLists.txt<br>
&gt; cmake_minimum_required(VERSION 2.8)<br>
&gt;<br>
&gt; FUNCTION(info_f)<br>
&gt;     set(msg &quot;&quot;)<br>
&gt;     foreach(part IN LISTS ARGN)<br>
&gt;           set(msg &quot;${msg}${part}&quot;)<br>
&gt;       endforeach()<br>
&gt;     message(&quot;[info_f] ${msg}&quot;)<br>
&gt; ENDFUNCTION()<br>
&gt;<br>
&gt; MACRO(info_m)<br>
&gt;     set(msg &quot;&quot;)<br>
&gt;     foreach(part IN LISTS ARGN)<br>
&gt;           set(msg &quot;${msg}${part}&quot;)<br>
&gt;       endforeach()<br>
&gt;     message(&quot;[info_m] ${msg}&quot;)<br>
&gt; ENDMACRO()<br>
&gt;<br>
&gt; message(&quot;foo;bar&quot;)<br>
&gt; info_f(&quot;foo;bar&quot;)<br>
&gt; info_m(&quot;foo;bar&quot;)<br>
&gt; $ cmake .<br>
&gt; foo;bar<br>
&gt; [info_f] foobar<br>
&gt; [info_m]<br>
&gt; $<br>
&gt;<br>
&gt; &gt; (I like ARGN since it is &#39;unnamed positional arguments&#39;. Since you have<br>
&gt; &gt; no named arguments, ARGV == ARGN, but generally speaking I can&#39;t think<br>
&gt; &gt; of why you&#39;d ever need to use ARGV.)<br>
&gt;<br>
&gt; Good point.<br>
&gt;<br>
&gt; &gt; --<br>
&gt; &gt; Matthew<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt;<br>
&gt; &gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt; &gt;<br>
&gt; &gt; Please keep messages on-topic and check the CMake FAQ at:<br>
</div></div>&gt; &gt; <a href="http://www.cmake.org/Wiki/**CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/**CMake_FAQ</a>&lt;<a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>



<div>&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Kitware offers various services to support the CMake community. For more<br>
&gt; &gt; information on each offering, please visit:<br>
&gt; &gt;<br>
&gt; &gt; CMake Support:<br>
</div>&gt; &gt; <a href="http://cmake.org/cmake/help/**support.html" target="_blank">http://cmake.org/cmake/help/**support.html</a>&lt;<a href="http://cmake.org/cmake/help/s" target="_blank">http://cmake.org/cmake/help/s</a><br>



&gt; &gt; upport.html&gt; CMake Consulting:<br>
&gt; &gt; <a href="http://cmake.org/cmake/help/**consulting.html" target="_blank">http://cmake.org/cmake/help/**consulting.html</a>&lt;<a href="http://cmake.org/cmake/hel" target="_blank">http://cmake.org/cmake/hel</a><br>



&gt; &gt; p/consulting.html&gt; CMake Training Courses:<br>
&gt; &gt; <a href="http://cmake.org/cmake/help/**training.html" target="_blank">http://cmake.org/cmake/help/**training.html</a>&lt;<a href="http://cmake.org/cmake/help/" target="_blank">http://cmake.org/cmake/help/</a><br>



&gt; &gt; training.html&gt;<br>
&gt; &gt;<br>
&gt; &gt; Visit other Kitware open-source projects at <a href="http://www.kitware.com/**" target="_blank">http://www.kitware.com/**</a><br>
&gt; &gt; opensource/opensource.html&lt;<a href="http://www.kitware.com/opensource/opensource.h" target="_blank">http://www.kitware.com/opensource/opensource.h</a><br>
&gt; &gt; tml&gt;<br>
<div>&gt; &gt;<br>
&gt; &gt; Follow this link to subscribe/unsubscribe:<br>
</div>&gt; &gt; <a href="http://www.cmake.org/mailman/**listinfo/cmake" target="_blank">http://www.cmake.org/mailman/**listinfo/cmake</a>&lt;<a href="http://www.cmake.org/mailma" target="_blank">http://www.cmake.org/mailma</a><br>



&gt; &gt; n/listinfo/cmake&gt;<br>
<div><div><br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div></div>