1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 19:43:23 +08:00

cmGlobalNinjaGenerator: Factor out GNU-like command-line detection on Windows

This commit is contained in:
Brad King
2023-03-18 11:20:00 -04:00
parent f79817fcf0
commit f3ca199c9b
2 changed files with 16 additions and 6 deletions

View File

@@ -63,6 +63,19 @@ std::string const cmGlobalNinjaGenerator::SHELL_NOOP = "cd .";
std::string const cmGlobalNinjaGenerator::SHELL_NOOP = ":"; std::string const cmGlobalNinjaGenerator::SHELL_NOOP = ":";
#endif #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==( bool operator==(
const cmGlobalNinjaGenerator::ByConfig::TargetDependsClosureKey& lhs, const cmGlobalNinjaGenerator::ByConfig::TargetDependsClosureKey& lhs,
const cmGlobalNinjaGenerator::ByConfig::TargetDependsClosureKey& rhs) const cmGlobalNinjaGenerator::ByConfig::TargetDependsClosureKey& rhs)
@@ -943,12 +956,8 @@ void cmGlobalNinjaGenerator::EnableLanguage(
mf->GetSafeDefinition(cmStrCat("CMAKE_", l, "_SIMULATE_ID")); mf->GetSafeDefinition(cmStrCat("CMAKE_", l, "_SIMULATE_ID"));
std::string const& compilerFrontendVariant = mf->GetSafeDefinition( std::string const& compilerFrontendVariant = mf->GetSafeDefinition(
cmStrCat("CMAKE_", l, "_COMPILER_FRONTEND_VARIANT")); cmStrCat("CMAKE_", l, "_COMPILER_FRONTEND_VARIANT"));
if ((compilerId == "Clang" && compilerFrontendVariant == "GNU") || this->SetUsingGCCOnWindows(
(simulateId != "MSVC" && DetectGCCOnWindows(compilerId, simulateId, compilerFrontendVariant));
(compilerId == "GNU" || compilerId == "QCC" ||
cmHasLiteralSuffix(compilerId, "Clang")))) {
this->UsingGCCOnWindows = true;
}
#endif #endif
} }
} }

View File

@@ -169,6 +169,7 @@ public:
const std::string& comment = ""); const std::string& comment = "");
bool IsGCCOnWindows() const { return this->UsingGCCOnWindows; } bool IsGCCOnWindows() const { return this->UsingGCCOnWindows; }
void SetUsingGCCOnWindows(bool b) { this->UsingGCCOnWindows = b; }
cmGlobalNinjaGenerator(cmake* cm); cmGlobalNinjaGenerator(cmake* cm);