[CMake] MACRO arguments
Brad King
brad.king at kitware.com
Thu Jun 15 10:20:01 EDT 2006
Filipe Sousa wrote:
> The fallowing code is making me crazy. I can't understand why the output is
> always FALSE
>
> MACRO(FOO1 x)
> IF(x)
This is the same as writing
IF(x)
outside the macro.
> MACRO(FOO2 x)
> IF(${x})
This is the same as writing
IF(hello)
outside the macro.
> MACRO(FOO3 x)
> IF("${x}")
This is the same as writing
IF("hello")
outside the macro.
Macro arguments are replaed by doing a string replacement of ${x} with
the value of the argument. They are NOT variables, which is why these
are called macros and not procedures or functions. You can convert
macro arguments to variables using the SET command:
MACRO(FOO4 x)
SET(X "${x}")
IF(X)
MESSAGE(TRUE)
ELSE(X)
MESSAGE(FALSE)
ENDIF(X)
ENDMACRO(FOO4)
-Brad
More information about the CMake
mailing list