mirror of
https://github.com/reactos/CMake.git
synced 2024-11-25 12:40:06 +00:00
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.
This commit is contained in:
parent
957c2aac7f
commit
378c2a0e86
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user