Hello, I'm testing the new FUNCTION command. In documentation says it'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't changes parent variables. Check the following example:<br>
<br><font face="Courier New, Courier, monospace">FUNCTION(MYTEST VAR1 VAR2 OUTPUTVAR)<br> MESSAGE(STATUS "OUTPUTVAR = ${OUTPUTVAR}")<br> SET(${OUTPUTVAR} "Values var1 = ${VAR1} var2 = ${VAR2}")<br>
MESSAGE(STATUS "${OUTPUTVAR}: ${${OUTPUTVAR}}")<br>ENDFUNCTION(MYTEST)<br><br>MESSAGE(STATUS "Test functions")<br><br>MYTEST("Hello" "World" MYMSG)<br>MESSAGE(STATUS ${MYMSG})<br>
<br>MYTEST("1" "2" MYMSG)<br>MESSAGE(STATUS ${MYMSG})<br><br>MYTEST("3" "4" MYMSG)<br>MESSAGE(STATUS ${MYMSG})</font><br><br>The output of executing this (with "cmake -P MyTest.cmake") it'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't changes the parent variable MYMSG?<br>Do I need to FORCE it?<br><br>Thanks.<br><br>(Sorry for my english :P)