[CMake] override variable in macro
Bill Hoffman
bill.hoffman at kitware.com
Fri Sep 21 13:45:13 EDT 2007
Juan Sanchez wrote:
> I would argue that the following snippet of code should either print
> "CAT" twice or die. Unfortunately it first prints "DOG" and then "CAT".
>
> Thanks,
>
> Juan
>
> MACRO(FOO BAR)
> SET (BAR "CAT")
> MESSAGE("${BAR}")
> ENDMACRO(FOO)
>
> FOO(DOG)
> MESSAGE("${BAR}")
>
>
So, expand the macro and you get:
SET(BAR "CAT") # text in a macro is just text, BAR is just more text
MESSAGE("DOG") # ${BAR} is replaced by DOG sort of like a cpp macro
MESSAGE(${BAR}) # now we print BAR which was set to CAT in the macro
-Bill
More information about the CMake
mailing list