[CMake] Using variable to store variable name

Paul Smyth paul.smyth at vicon.com
Tue Apr 5 08:15:04 EDT 2005


Hi folks,
This seems to me like a dumb question; but I can't seem to find the
answer, in all my searching.

You can build a variable name from a the value of another variable. And
then extract the value pointed to my the built variable name.
Like so: (taken from UseSWIG.cmake)
${SWIG_MODULE_${name}_REAL_NAME}

However, in the simpler case, if you have a variable A whose contents
are another variable name B, the you don't seem to be able to extract
the value of variable B.
e.g.

SET(B "BVALUE")
SET(A "B")

WRITE_FILE("C:\\Temp\\Libs.txt" "A = <${A}>" APPEND )
WRITE_FILE("C:\\Temp\\Libs.txt" "B = <${B}>" APPEND )
WRITE_FILE("C:\\Temp\\Libs.txt" "B's value from A = <${${A}}>" APPEND )

This results in 
AVAR = <BVAR>
BVAR = <BVALUE>
BVAR's value from AVAR = <}>

Which is obviously not right.

Am I realistic in expecting this to work?
Why does it seem to work in the case of aggregating names, but not more
directly?
Is there a workaround or fix about?
If it should work, then I might look a bit harder at the parsing code,
but it's a bit yucky.

Thanks for any help you can give,
Paul Smyth

________________________________________________________________________
This e-mail, and any attachment, is confidential. If you have received it in error, do not use or disclose the information in any way, notify me immediately, and please delete it from your system.
________________________________________________________________________


More information about the CMake mailing list