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.
Because of this, I want to port all my macros to functions, but it doesn't
changes parent variables. Check the following example:

FUNCTION(MYTEST VAR1 VAR2 OUTPUTVAR)
    MESSAGE(STATUS "OUTPUTVAR = ${OUTPUTVAR}")
    SET(${OUTPUTVAR} "Values var1 = ${VAR1} var2 = ${VAR2}")
    MESSAGE(STATUS "${OUTPUTVAR}: ${${OUTPUTVAR}}")
ENDFUNCTION(MYTEST)

MESSAGE(STATUS "Test functions")

MYTEST("Hello" "World" MYMSG)
MESSAGE(STATUS ${MYMSG})

MYTEST("1" "2" MYMSG)
MESSAGE(STATUS ${MYMSG})

MYTEST("3" "4" MYMSG)
MESSAGE(STATUS ${MYMSG})

The output of executing this (with "cmake -P MyTest.cmake") it's the
following:
-- Test functions
-- OUTPUTVAR = MYMSG
-- MYMSG: Values var1 = Hello var2 = World
--
-- OUTPUTVAR = MYMSG
-- MYMSG: Values var1 = 1 var2 = 2
--
-- OUTPUTVAR = MYMSG
-- MYMSG: Values var1 = 3 var2 = 4
--

Why MYTEST function doesn't changes the parent variable MYMSG?
Do I need to FORCE it?

Thanks.

(Sorry for my english :P)

Attachment: MyTest.cmake
Description: Binary data

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to