Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake interpret string as variable

Tags:

cmake

I'm looking for a way to interpret a string as variable name in cmake.

Given:

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"
like image 352
Denis Blank Avatar asked Sep 17 '15 13:09

Denis Blank


1 Answers

A second level of unwrapping:

set(THE_VALUE "${${THE_NAME}}")
like image 102
Gombat Avatar answered Nov 09 '22 23:11

Gombat