Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CMake将字符串解释为变量_Cmake - Fatal编程技术网

CMake将字符串解释为变量

CMake将字符串解释为变量,cmake,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}")

我正在寻找一种在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"

第二级展开:

set(THE_VALUE "${${THE_NAME}}")