Ninja: Use forward slashes for any GCC on Windows (#15439)

Any GCC compiler on a Windows host needs forward slashes, not just
those built for MinGW.
This commit is contained in:
Thomas Herz 2015-05-07 00:45:01 +02:00 committed by Brad King
parent 378c2a0e86
commit b3de0dfe93
3 changed files with 11 additions and 7 deletions

View File

@ -96,7 +96,7 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path)
{
std::string result = path;
#ifdef _WIN32
if (this->IsMinGW())
if (this->IsGCCOnWindows())
cmSystemTools::ReplaceString(result, "\\", "/");
else
cmSystemTools::ReplaceString(result, "/", "\\");
@ -484,7 +484,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
, CompileCommandsStream(0)
, Rules()
, AllDependencies()
, UsingMinGW(false)
, UsingGCCOnWindows(false)
, ComputingUnknownDependencies(false)
, PolicyCMP0058(cmPolicies::WARN)
{
@ -565,9 +565,13 @@ void cmGlobalNinjaGenerator
this->ResolveLanguageCompiler(*l, mf, optional);
}
#ifdef _WIN32
if (mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
if (mf->IsOn("CMAKE_COMPILER_IS_MINGW") ||
strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "GNU") == 0 ||
strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "GNU") == 0 ||
strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "GNU") == 0 ||
strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "GNU") == 0)
{
this->UsingMinGW = true;
this->UsingGCCOnWindows = true;
}
#endif
}

View File

@ -155,7 +155,7 @@ public:
const cmNinjaDeps& targets,
const std::string& comment = "");
bool IsMinGW() const { return this->UsingMinGW; }
bool IsGCCOnWindows() const { return UsingGCCOnWindows; }
public:
/// Default constructor.
@ -360,7 +360,7 @@ private:
/// The set of dependencies to add to the "all" target.
cmNinjaDeps AllDependencies;
bool UsingMinGW;
bool UsingGCCOnWindows;
/// The set of custom commands we have seen.
std::set<cmCustomCommand const*> CustomCommands;

View File

@ -175,7 +175,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
// needed by cmcldeps
false,
this->GetConfigName());
if (this->GetGlobalGenerator()->IsMinGW())
if (this->GetGlobalGenerator()->IsGCCOnWindows())
cmSystemTools::ReplaceString(includeFlags, "\\", "/");
this->LocalGenerator->AppendFlags(languageFlags, includeFlags);