For building applications I use CMake. I parse my CMake command in a script with several variables:
CMAKE_COMMAND=" \
$CMAKE \
-G "$Build_TOOL_CMAKE" \
[...]"
After parsing that command I print it with printf
for control:
printf "\n${CMAKE_COMMAND}\n"
And then I eventually execute the command with:
$CMAKE_COMMAND
This script worked as long as I had "Ninja" as Generator (the -G
option --> BUILD_TOOL_CMAKE="Ninja"
) as it does have no space characters in it.
Now I want to use "Eclipse CDT4 - Unix Makefiles" as Generator. I tried several ways of escaping the space characters, e.g.:
CMAKE_COMMAND=" \
$CMAKE \
-G \"$Build_TOOL_CMAKE\" \
[...]"
or
CMAKE_COMMAND=" \
$CMAKE \
-G '$Build_TOOL_CMAKE' \
[...]"
The printed command became correct in some cases, but the execution of it resulted in errors like:
CMake Error: Could not create named generator Eclipse
or
CMake Error: Could not create named generator "Eclipse
This leads to the assumption that something is wrong with escaping the spaces, but the printf
works:
cmake.exe -G"Eclipse CDT4 - Unix Makefiles" -S sourcefolder -B buildfolder # printf $CMAKE_COMMAND
Did I miss something? Maybe the executing merely by the variable ($CMAKE_COMMAND
) is also the wrong approach.