> On Nov 10, 2017, at 6:49 AM, stefan.waig...@continental-corporation.com wrote:
> 
> 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


perhaps handle arguments as an array variable in bash - it’s a slightly saner 
way to deal with args with spaces:

CMDLINE=(. -G"Unix Makefiles") && cmake "${CMDLINE[@]}”

-Mike

Attachment: signature.asc
Description: Message signed with OpenPGP

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to