[CMake] different behaviour of the same code
Andy Cedilnik
andy.cedilnik at kitware.com
Thu Dec 30 13:02:14 EST 2004
Hi Eddy,
The syntax ${${foo}} only works inside FOREACH and MACRO and even there
only for the actual arguments. For example:
MACRO(macro FOO)
MESSAGE("${${FOO}}")
ENDMACRO(macro)
SET(BAR "Hello world")
macro(BAR)
will work because the argument ${FOO} is string replaced by BAR, which
is then evaluated to "Hello world". That said, the following will not work:
SET(BAR "Hello world")
SET(FOO BAR)
MACRO(macro)
MESSAGE("${${FOO}}")
ENDMACRO(macro)
You should put feature request to cmake bug tracker www.cmake.org/Bug
for full support of ${${...}} syntax.
Andy
Eddy Pronk wrote:
> Fiddling around with macros, I found out there is different behaviour
> of the same code [${${component}_lib}].
> Maybe usage of variables as in M2 is not a good idea, but the output
> seems unexpected.
>
> MACRO(M1 component)
> MESSAGE("M1 called for ${component}")
> MESSAGE(${${component}_lib}) # works
> ENDMACRO(M1)
>
> MACRO(M2)
> MESSAGE("M2 called for ${component}")
> MESSAGE(${${component}_lib}) # unexpected output
> ENDMACRO(M2)
>
> SET(foo_lib mylib)
>
> SET(component foo) # global scope
>
> M1(foo)
> M2()
>
> MESSAGE(${${component}_lib}) # unexpected output
>
>
> $ cmake --version
> cmake version 2.0.5
>
>
> Eddy Pronk
> _______________________________________________
> CMake mailing list
> CMake at www.cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
--
Andy Cedilnik
Kitware Inc.
More information about the CMake
mailing list