CMake将字符串解释为变量 [英] CMake interpret string as variable
本文介绍了CMake将字符串解释为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种在cmake中将字符串解释为变量名的方法。
I'm looking for a way to interpret a string as variable name in 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}}")
这篇关于CMake将字符串解释为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文