CMake将字符串解释为变量

时间:2015-09-17 13:10:42

标签: cmake

我正在寻找一种方法将字符串解释为cmake中的变量名。

假设:

set(MY_SECRET_VAR "foo")

# later only the name of the variable is known.
set(THE_NAME "MY_SECRET_VAR")

# Now i'm looking for a way to get the value "foo" from the name
# something like:
set(THE_VALUE "${THE_NAME}")

# THE_VALUE should be "foo"

1 个答案:

答案 0 :(得分:12)

第二级展开:

set(THE_VALUE "${${THE_NAME}}")
相关问题