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
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to