1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-21 14:40:48 +08:00

cmLocalNinjaGenerator: De-duplicate condition for using 'cmd /C' on Windows

This commit is contained in:
Brad King
2023-03-16 17:07:53 -04:00
parent 8ebe3f92b3
commit edab56d29a

View File

@@ -498,12 +498,12 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
} }
std::ostringstream cmd; std::ostringstream cmd;
for (auto li = cmdLines.begin(); li != cmdLines.end(); ++li)
#ifdef _WIN32 #ifdef _WIN32
{ bool const needCMD = cmdLines.size() > 1;
for (auto li = cmdLines.begin(); li != cmdLines.end(); ++li) {
if (li != cmdLines.begin()) { if (li != cmdLines.begin()) {
cmd << " && "; cmd << " && ";
} else if (cmdLines.size() > 1) { } else if (needCMD) {
cmd << "cmd.exe /C \""; cmd << "cmd.exe /C \"";
} }
// Put current cmdLine in brackets if it contains "||" because it has // Put current cmdLine in brackets if it contains "||" because it has
@@ -514,11 +514,11 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
cmd << *li; cmd << *li;
} }
} }
if (cmdLines.size() > 1) { if (needCMD) {
cmd << "\""; cmd << "\"";
} }
#else #else
{ for (auto li = cmdLines.begin(); li != cmdLines.end(); ++li) {
if (li != cmdLines.begin()) { if (li != cmdLines.begin()) {
cmd << " && "; cmd << " && ";
} }