MantisBT - CMake
View Issue Details
0008397CMakeCMakepublic2009-01-19 02:562009-01-20 08:13
Philip Lowman 
Brad King 
normalmajoralways
closedwon't fix 
 
 
0008397: MACRO bug with constants
The FUNCTION works but the MACRO doesn't.

MACRO(test_constants_macro _a )
     MESSAGE("a = ${_a}")
     IF(_a)
         MESSAGE("test_constants_macro: a is true")
     ELSE()
         MESSAGE("test_constants_macro: ERROR: a is FALSE!")
     ENDIF()
ENDMACRO()
FUNCTION(test_constants_func _a )
     MESSAGE("a = ${_a}")
     IF(_a)
         MESSAGE("test_constants_func: a is true")
     ELSE()
         MESSAGE("test_constants_func: ERROR: a is FALSE!")
     ENDIF()
ENDFUNCTION()

test_constants_macro(1)
test_constants_macro(TRUE)
test_constants_macro(ON)
test_constants_func(1)
test_constants_func(TRUE)
test_constants_func(ON)

a = 1
test_constants_macro: ERROR: a is FALSE!
a = TRUE
test_constants_macro: ERROR: a is FALSE!
a = ON
test_constants_macro: ERROR: a is FALSE!
a = 1
test_constants_func: a is true
a = TRUE
test_constants_func: a is true
a = ON
test_constants_func: a is true
No tags attached.
Issue History
2009-01-19 02:56Philip LowmanNew Issue
2009-01-19 18:07Bill HoffmanStatusnew => assigned
2009-01-19 18:07Bill HoffmanAssigned To => Brad King
2009-01-20 08:12Brad KingNote Added: 0014643
2009-01-20 08:13Brad KingStatusassigned => closed
2009-01-20 08:13Brad KingResolutionopen => won't fix

Notes
(0014643)
Brad King   
2009-01-20 08:12   
From the documentation of MACRO:

When it is invoked, the commands recorded in the macro are first modified by replacing formal parameters (${arg1}) with the arguments passed, and then invoked as normal commands.

Only the ${} syntax usage gets replaced. Macro arguments are not real variables.