<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Oct 5, 2013 at 1:38 AM, Matthew Woehlke <span dir="ltr">&lt;<a href="mailto:matthew.woehlke@kitware.com" target="_blank">matthew.woehlke@kitware.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im">On 2013-09-27 04:18, Clark WANG wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im">
I&#39;m trying to write some MESSAGE() wrappers like info(), warning(),<br>
fatal(), etc which may be a bit easier to use. But I failed to simulate the<br>
correct MESSAGE() behavior no matter I use MACRO or FUNCTION. For example:<br></div>
[snip]<br>
</blockquote>
<br>
FUNCTION vs MACRO shouldn&#39;t make a difference in argument parsing AFAIK. The difference is primarily that FUNCTION creates a scope, while MACRO operates in the scope from which it is called.<br>
<br>
The behavior of MESSAGE seems to concatenate multiple arguments with no separators. So maybe you could do something like:<br>
<br>
set(msg &quot;&quot;)<br>
foreach(part IN LISTS ARGN)<br>
  set(msg &quot;${msg}{$part}&quot;)<br>
endforeach()<br>
# ...do stuff with ${msg}<br></blockquote><div><br></div><div>This does not work either. For example:<br><br></div><div>$ cat CMakeLists.txt <br>cmake_minimum_required(VERSION 2.8)<br><br>FUNCTION(info_f)<br>    set(msg &quot;&quot;)<br>

    foreach(part IN LISTS ARGN)<br>          set(msg &quot;${msg}${part}&quot;)<br>      endforeach()<br>    message(&quot;[info_f] ${msg}&quot;)<br>ENDFUNCTION()<br><br>MACRO(info_m)<br>    set(msg &quot;&quot;)<br>    foreach(part IN LISTS ARGN)<br>

          set(msg &quot;${msg}${part}&quot;)<br>      endforeach()<br>    message(&quot;[info_m] ${msg}&quot;)<br>ENDMACRO()<br><br>message(&quot;foo;bar&quot;)<br>info_f(&quot;foo;bar&quot;)<br>info_m(&quot;foo;bar&quot;)<br>

</div><div>$ cmake .<br>foo;bar<br>[info_f] foobar<br>[info_m]<br>$ <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
(I like ARGN since it is &#39;unnamed positional arguments&#39;. Since you have no named arguments, ARGV == ARGN, but generally speaking I can&#39;t think of why you&#39;d ever need to use ARGV.)<br></blockquote><div><br>

</div><div>Good point. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- <br>
Matthew<br>
<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/<u></u>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/<u></u>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/<u></u>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/<u></u>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/<u></u>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/<u></u>listinfo/cmake</a><br>
</blockquote></div><br></div></div>