Why doesn't the following command work?
SET(MY_LIST a b c d) LIST(GET ${MY_LIST} 0 HEAD) MESSAGE("HEAD = ${HEAD}")
I want it to assign a
to HEAD
but instead I'm getting NOTFOUND
.
I have already tried surrounding ${MY_LIST}
with double quotes and changing the index to 1 instead of 0 (don't know why someone would do that but it didn't hurt to try).
A list in cmake is a ; separated group of strings. To create a list the set command can be used. For example, set(var a b c d e) creates a list with a;b;c;d;e , and set(var "a b c d e") creates a string or a list with one item in it.
CMakeLists. txt file contains a set of directives and instructions describing the project's source files and targets (executable, library, or both). When you create a new project, CLion generates CMakeLists. txt file automatically and places it in the project root directory.
You can use the command line to set entries in the Cache with the syntax cmake -D var:type=value , just cmake -D var=value or with cmake -C CMakeInitialCache. cmake . You can unset entries in the Cache with unset(... CACHE) .
The list commands require an unsubstituted variable as the second argument, i.e.:
set (MY_LIST a b c d) list (GET MY_LIST 0 HEAD) message ("HEAD = ${HEAD}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With