From b6f1142c8b712fb5ebfd2515a400a0b5ac621a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Mon, 25 Nov 2013 11:17:14 +0100 Subject: [PATCH] Ninja: multiple commands must be quoted Bug 14370 --- Source/cmLocalNinjaGenerator.cxx | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index f1d5e2cf1..84d89df14 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -287,16 +287,32 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( cmOStringStream cmd; for (std::vector::const_iterator li = cmdLines.begin(); - li != cmdLines.end(); ++li) { - if (li != cmdLines.begin()) { - cmd << " && "; + li != cmdLines.end(); ++li) #ifdef _WIN32 - } else if (cmdLines.size() > 1) { - cmd << "cmd.exe /c "; -#endif - } + { + if (li != cmdLines.begin()) + { + cmd << " && "; + } + else if (cmdLines.size() > 1) + { + cmd << "cmd.exe /C \""; + } cmd << *li; - } + } + if (cmdLines.size() > 1) + { + cmd << "\""; + } +#else + { + if (li != cmdLines.begin()) + { + cmd << " && "; + } + cmd << *li; + } +#endif return cmd.str(); }