[CMake] spaces in generator strings troublesome
Stefan.Waigand at continental-corporation.com
Stefan.Waigand at continental-corporation.com
Fri Nov 10 09:49:39 EST 2017
Hello,
the usual way to pass a generator string to the cmake executable on the
command line is:
cmake . -G"Unix Makefiles"
But when i have some bash scripting around it and try to hold the command
line arguments in a variable, the trouble begins...
export CMDLINE=". -G\"Unix Makefiles\"" && cmake $CMDLINE
-> CMake Error: Could not create named generator "Unix
The reason seems to be bash separates arguments by spaces, and does not
care for the quotes.
I tried to escape the space character somehow, but nothing seems to help:
export CMDLINE=". -G\"Unix\ Makefiles\"" && cmake $CMDLINE
-> CMake Error: Could not create named generator "Unix\
export CMDLINE=". -G'Unix Makefiles'" && cmake $CMDLINE
-> CMake Error: Could not create named generator 'Unix
Now there might be ways how to work around this in bash. E.g. by quoting
arguments on their own as done here
https://stackoverflow.com/questions/42111441/how-to-pass-command-line-arguments-with-spaces-through-a-variable-in-bash
or here
https://unix.stackexchange.com/questions/108635/why-i-cant-escape-spaces-on-a-bash-script
But this is more complicated, harder to understand and maintain - not a
nice solution.
Looking around, i do not seem to be alone with this kind of problem.
Example
https://stackoverflow.com/questions/20570042/calling-cmake-with-bash-variable-argument
So here is my plea to the CMake developers and feature request:
Could you please let CMake support this kind of command line?
cmake . -GUnix_Makefiles
i mean besides the established way CMake should accept the generator
strings with '_' instead of ' '?
If the command line parser could replace '_' by ' ' things would be
backward compatible, right?
This would solve problems as mentioned above and help people to automate
their CMake environments.
Thank you,
Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171110/23ca01a3/attachment.html>
More information about the CMake
mailing list