summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-18 15:20:00 (GMT)
committerBrad King <brad.king@kitware.com>2023-03-18 15:52:41 (GMT)
commitf3ca199c9b26988645fe1da661687238c407c24e (patch)
tree7535f1a63161d7f8bb6ad474ad7b40384b619960
parentf79817fcf0168c377ea4cb7187830a8caf373168 (diff)
downloadCMake-f3ca199c9b26988645fe1da661687238c407c24e.zip
CMake-f3ca199c9b26988645fe1da661687238c407c24e.tar.gz
CMake-f3ca199c9b26988645fe1da661687238c407c24e.tar.bz2
cmGlobalNinjaGenerator: Factor out GNU-like command-line detection on Windows
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx21
-rw-r--r--Source/cmGlobalNinjaGenerator.h1
2 files changed, 16 insertions, 6 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index e739038..97366c2 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -63,6 +63,19 @@ std::string const cmGlobalNinjaGenerator::SHELL_NOOP = "cd .";
std::string const cmGlobalNinjaGenerator::SHELL_NOOP = ":";
#endif
+namespace {
+#ifdef _WIN32
+bool DetectGCCOnWindows(cm::string_view compilerId, cm::string_view simulateId,
+ cm::string_view compilerFrontendVariant)
+{
+ return ((compilerId == "Clang"_s && compilerFrontendVariant == "GNU"_s) ||
+ (simulateId != "MSVC"_s &&
+ (compilerId == "GNU"_s || compilerId == "QCC"_s ||
+ cmHasLiteralSuffix(compilerId, "Clang"))));
+}
+#endif
+}
+
bool operator==(
const cmGlobalNinjaGenerator::ByConfig::TargetDependsClosureKey& lhs,
const cmGlobalNinjaGenerator::ByConfig::TargetDependsClosureKey& rhs)
@@ -943,12 +956,8 @@ void cmGlobalNinjaGenerator::EnableLanguage(
mf->GetSafeDefinition(cmStrCat("CMAKE_", l, "_SIMULATE_ID"));
std::string const& compilerFrontendVariant = mf->GetSafeDefinition(
cmStrCat("CMAKE_", l, "_COMPILER_FRONTEND_VARIANT"));
- if ((compilerId == "Clang" && compilerFrontendVariant == "GNU") ||
- (simulateId != "MSVC" &&
- (compilerId == "GNU" || compilerId == "QCC" ||
- cmHasLiteralSuffix(compilerId, "Clang")))) {
- this->UsingGCCOnWindows = true;
- }
+ this->SetUsingGCCOnWindows(
+ DetectGCCOnWindows(compilerId, simulateId, compilerFrontendVariant));
#endif
}
}
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index f18d63b..68b26cc 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -169,6 +169,7 @@ public:
const std::string& comment = "");
bool IsGCCOnWindows() const { return this->UsingGCCOnWindows; }
+ void SetUsingGCCOnWindows(bool b) { this->UsingGCCOnWindows = b; }
cmGlobalNinjaGenerator(cmake* cm);