summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-05-07 18:01:58 (GMT)
committerBrad King <brad.king@kitware.com>2015-05-07 18:02:44 (GMT)
commit378c2a0e860f32e0435844d7d6af79a4fdc2b455 (patch)
tree3ab57abbcb7c76aeeafe4ff28316284ceea122af
parent957c2aac7fb4833b333cf3362cb8c6918a8e8a82 (diff)
downloadCMake-378c2a0e860f32e0435844d7d6af79a4fdc2b455.zip
CMake-378c2a0e860f32e0435844d7d6af79a4fdc2b455.tar.gz
CMake-378c2a0e860f32e0435844d7d6af79a4fdc2b455.tar.bz2
Ninja: Refactor detection of MinGW tools on Windows
Check for CMAKE_COMPILER_IS_MINGW only after enabling a language when it might actually be set. Previously this worked by accident because the check for working compiler or a second language enabled would cause the code path to be taken. Store UsingMinGW as an instance member of cmGlobalNinjaGenerator so that it is reset on each reconfigure. Otherwise cmake-gui cannot switch between build trees for MinGW or non-MinGW tools.
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx24
-rw-r--r--Source/cmGlobalNinjaGenerator.h11
-rw-r--r--Source/cmNinjaTargetGenerator.cxx2
3 files changed, 16 insertions, 21 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 9a017e5..9894aa8 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -96,7 +96,7 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path)
{
std::string result = path;
#ifdef _WIN32
- if(UsingMinGW)
+ if (this->IsMinGW())
cmSystemTools::ReplaceString(result, "\\", "/");
else
cmSystemTools::ReplaceString(result, "/", "\\");
@@ -484,6 +484,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
, CompileCommandsStream(0)
, Rules()
, AllDependencies()
+ , UsingMinGW(false)
, ComputingUnknownDependencies(false)
, PolicyCMP0058(cmPolicies::WARN)
{
@@ -544,23 +545,16 @@ void cmGlobalNinjaGenerator::Generate()
this->CloseBuildFileStream();
}
-// Implemented in all cmGlobaleGenerator sub-classes.
-// Used in:
-// Source/cmMakefile.cxx:
void cmGlobalNinjaGenerator
::EnableLanguage(std::vector<std::string>const& langs,
- cmMakefile* makefile,
+ cmMakefile* mf,
bool optional)
{
- if (makefile->IsOn("CMAKE_COMPILER_IS_MINGW"))
- {
- UsingMinGW = true;
- }
if (std::find(langs.begin(), langs.end(), "Fortran") != langs.end())
{
cmSystemTools::Error("The Ninja generator does not support Fortran yet.");
}
- this->cmGlobalGenerator::EnableLanguage(langs, makefile, optional);
+ this->cmGlobalGenerator::EnableLanguage(langs, mf, optional);
for(std::vector<std::string>::const_iterator l = langs.begin();
l != langs.end(); ++l)
{
@@ -568,12 +562,16 @@ void cmGlobalNinjaGenerator
{
continue;
}
- this->ResolveLanguageCompiler(*l, makefile, optional);
+ this->ResolveLanguageCompiler(*l, mf, optional);
}
+#ifdef _WIN32
+ if (mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
+ {
+ this->UsingMinGW = true;
+ }
+#endif
}
-bool cmGlobalNinjaGenerator::UsingMinGW = false;
-
// Implemented by:
// cmGlobalUnixMakefileGenerator3
// cmGlobalGhsMultiGenerator
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index d7b3add..9b6717a 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -63,7 +63,7 @@ public:
static std::string EncodeIdent(const std::string &ident, std::ostream &vars);
static std::string EncodeLiteral(const std::string &lit);
- static std::string EncodePath(const std::string &path);
+ std::string EncodePath(const std::string &path);
static std::string EncodeDepfileSpace(const std::string &path);
/**
@@ -155,9 +155,7 @@ public:
const cmNinjaDeps& targets,
const std::string& comment = "");
-
- static bool IsMinGW() { return UsingMinGW; }
-
+ bool IsMinGW() const { return this->UsingMinGW; }
public:
/// Default constructor.
@@ -362,6 +360,8 @@ private:
/// The set of dependencies to add to the "all" target.
cmNinjaDeps AllDependencies;
+ bool UsingMinGW;
+
/// The set of custom commands we have seen.
std::set<cmCustomCommand const*> CustomCommands;
@@ -385,9 +385,6 @@ private:
typedef std::map<std::string, cmTarget*> TargetAliasMap;
TargetAliasMap TargetAliases;
-
- static bool UsingMinGW;
-
};
#endif // ! cmGlobalNinjaGenerator_h
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index dfd3c04..a3c9be6 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -175,7 +175,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
// needed by cmcldeps
false,
this->GetConfigName());
- if(cmGlobalNinjaGenerator::IsMinGW())
+ if (this->GetGlobalGenerator()->IsMinGW())
cmSystemTools::ReplaceString(includeFlags, "\\", "/");
this->LocalGenerator->AppendFlags(languageFlags, includeFlags);