gpt4 book ai didi

cmake - CMake将字符串解释为变量

转载 作者:行者123 更新时间:2023-12-04 03:20:11 24 4
gpt4 key购买 nike

我正在寻找一种在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 - CMake将字符串解释为变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32631168/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com