FAQ: Why do I have unwanted semicolons incorrect description
if you pass ${var} to a non-CMake external tool, such as a compiler's command line,
you are passing a;b;c;d;e which is not what you want.
Instead you either need to pass "${var}", so that the list will be converted
to a whitespace-separated string
Is it not the other way around? If var
contains a;b;c
then surrounding it with double quotes (f1.cmake
below) will keep the semicolons, whereas a plain ${var}
(f2.cmake
below) will expand to space separated items.
bash$ cmake --version
cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
bash$ cat f1.cmake
set(var a b c)
execute_process(COMMAND "echo" "${var}")
bash$ cmake -P f1.cmake
a;b;c
bash$ cat f2.cmake
set(var a b c)
execute_process(COMMAND "echo" ${var})
bash$ cmake -P f2.cmake
a b c
bash$