-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Modern CMake for C++
By :
To store a list, CMake concatenates all elements into a string, using a semicolon (;) as a delimiter: a;list;of;5;elements. You can escape a semicolon in an element with a backslash, like so: a\;single\;element.
To create a list, we can use the set() command: set(myList a list of five elements). Because of how lists are stored, the following commands will have exactly the same effect:
set(myList "a;list;of;five;elements")set(myList a list "of;five;elements")CMake automatically unpacks lists in unquoted arguments. By passing an unquoted myList reference, we effectively send more arguments to the command:
message("the list is:" ${myList})
The message() command will receive here six arguments: "the list is:", "a", "list", "of", "five", "elements". This may have unintended consequences, as the output will be printed without any additional spaces between...