&gt; Why MYTEST function doesn&#39;t changes the parent variable MYMSG?<br>&gt; Do I need to FORCE it?<br><br><div>No, you need to PARENT_SCOPE it. See cmake --help-command SET for details about PARENT_SCOPE.</div><div><br>
</div><div>HTH,</div><div>David</div><div><br><div class="gmail_quote">On Wed, Apr 23, 2008 at 11:29 AM, Alejandro Morell Garcia &lt;<a href="mailto:alejandro.morell@gmail.com">alejandro.morell@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">&nbsp;Hello, I&#39;m testing the new FUNCTION command. In documentation says it&#39;s the same as a MACRO but local variables are deleted at exit.<br>
Because of this, I want to port all my macros to functions, but it doesn&#39;t changes parent variables. Check the following example:<br>
<br><font face="Courier New, Courier, monospace">FUNCTION(MYTEST VAR1 VAR2 OUTPUTVAR)<br>&nbsp;&nbsp;&nbsp; MESSAGE(STATUS &quot;OUTPUTVAR = ${OUTPUTVAR}&quot;)<br>&nbsp;&nbsp;&nbsp; SET(${OUTPUTVAR} &quot;Values var1 = ${VAR1} var2 = ${VAR2}&quot;)<br>

&nbsp;&nbsp;&nbsp; MESSAGE(STATUS &quot;${OUTPUTVAR}: ${${OUTPUTVAR}}&quot;)<br>ENDFUNCTION(MYTEST)<br><br>MESSAGE(STATUS &quot;Test functions&quot;)<br><br>MYTEST(&quot;Hello&quot; &quot;World&quot; MYMSG)<br>MESSAGE(STATUS ${MYMSG})<br>

<br>MYTEST(&quot;1&quot; &quot;2&quot; MYMSG)<br>MESSAGE(STATUS ${MYMSG})<br><br>MYTEST(&quot;3&quot; &quot;4&quot; MYMSG)<br>MESSAGE(STATUS ${MYMSG})</font><br><br>The output of executing this (with &quot;cmake -P MyTest.cmake&quot;) it&#39;s the following:<br>

<font face="Verdana">-- Test functions<br>-- OUTPUTVAR = MYMSG<br>-- MYMSG: Values var1 = Hello var2 = World<br>--<br>-- OUTPUTVAR = MYMSG<br>-- MYMSG: Values var1 = 1 var2 = 2<br>--<br>-- OUTPUTVAR = MYMSG<br>-- MYMSG: Values var1 = 3 var2 = 4<br>

--</font><br><br>Why MYTEST function doesn&#39;t changes the parent variable MYMSG?<br>Do I need to FORCE it?<br><br>Thanks.<br><br>(Sorry for my english :P)
<br>_______________________________________________<br>
CMake mailing list<br>
<a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br></div>