diff options
author | Brad King <brad.king@kitware.com> | 2023-03-16 21:07:53 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-03-18 15:52:41 (GMT) |
commit | edab56d29a4910ff9365c3ee673a0ab81d25005b (patch) | |
tree | 52ed49e0610566334e39f7d0390126c9ea707b9b | |
parent | 8ebe3f92b3b270dca340ccceb34a751d213465a2 (diff) | |
download | CMake-edab56d29a4910ff9365c3ee673a0ab81d25005b.zip CMake-edab56d29a4910ff9365c3ee673a0ab81d25005b.tar.gz CMake-edab56d29a4910ff9365c3ee673a0ab81d25005b.tar.bz2 |
cmLocalNinjaGenerator: De-duplicate condition for using 'cmd /C' on Windows
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 1e2ea2a..77c5a76 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -498,12 +498,12 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( } std::ostringstream cmd; - for (auto li = cmdLines.begin(); li != cmdLines.end(); ++li) #ifdef _WIN32 - { + bool const needCMD = cmdLines.size() > 1; + for (auto li = cmdLines.begin(); li != cmdLines.end(); ++li) { if (li != cmdLines.begin()) { cmd << " && "; - } else if (cmdLines.size() > 1) { + } else if (needCMD) { cmd << "cmd.exe /C \""; } // Put current cmdLine in brackets if it contains "||" because it has @@ -514,11 +514,11 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( cmd << *li; } } - if (cmdLines.size() > 1) { + if (needCMD) { cmd << "\""; } #else - { + for (auto li = cmdLines.begin(); li != cmdLines.end(); ++li) { if (li != cmdLines.begin()) { cmd << " && "; } |