cmake Variables and Properties Strings and Lists


It's important to know how CMake distinguishes between lists and plain strings. When you write:

set(VAR "a b c")

you create a string with the value "a b c". But when you write this line without quotes:

set(VAR a b c)

You create a list of three items instead: "a", "b" and "c".

Non-list variables are actually lists too (of a single element).

Lists can be operated on with the list() command, which allows concatenating lists, searching them, accessing arbitrary elements and so on (documentation of list()).

Somewhat confusing, a list is also a string. The line

set(VAR a b c)

is equivalent to

set(VAR "a;b;c")

Therefore, to concatenate lists one can also use the set() command: