Question: I am confused with a very simple example. I have a standard list, so basically its string representation uses semicolon as delimiters. I want to replace it by another one:

```
set(L1 "A" "B" "C")
message("L1: ${L1}")

string(REPLACE ";" "<->" L2 ${L1})
message("L2: ${L2}")

```

this snippet prints:

```
L1: A;B;C
L2: ABC

```

and I don't understand why. According [to some other SO answers](https://stackoverflow.com/a/7172941/1887976), my string replacement seems valid. What am I doing wrong ? Is there a way to store the value `A<->B<->C` in my 2nd variable ?

Note: I use CMake 3.7.2

Answer: 
Just put `${L1}` in quotes:

```
set(L1 "A" "B" "C")
message("L1: ${L1}")

string(REPLACE ";" "<->" L2 "${L1}")
message("L2: ${L2}")

```

Otherwise the list will be expanded again to a space separated parameter list. 

**Reference**

* [cmake: when to quote variables?](https://stackoverflow.com/questions/35847655/cmake-when-to-quote-variables)
But `${L1}` *isn't* a string, it's a list. If you want a string then you need to enclose it in double-quotes like `"${L1}"`.