Ninja: Refactor ninja feature detection

Check for features as soon as we know the ninja version.  Save the
results so we do not have to re-compare versions every time.
This commit is contained in:
Brad King 2016-09-21 14:22:41 -04:00
parent f0a23aa3db
commit 0488ae63ea
2 changed files with 18 additions and 6 deletions

View File

@ -473,6 +473,8 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
, UsingGCCOnWindows(false)
, ComputingUnknownDependencies(false)
, PolicyCMP0058(cmPolicies::WARN)
, NinjaSupportsConsolePool(false)
, NinjaSupportsImplicitOuts(false)
{
#ifdef _WIN32
cm->GetState()->SetWindowsShell(true);
@ -558,9 +560,20 @@ void cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf)
cmSystemTools::RunSingleCommand(command, &version, CM_NULLPTR, CM_NULLPTR,
CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
this->NinjaVersion = cmSystemTools::TrimWhitespace(version);
this->CheckNinjaFeatures();
}
}
void cmGlobalNinjaGenerator::CheckNinjaFeatures()
{
this->NinjaSupportsConsolePool = !cmSystemTools::VersionCompare(
cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
RequiredNinjaVersionForConsolePool().c_str());
this->NinjaSupportsImplicitOuts = !cmSystemTools::VersionCompare(
cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
this->RequiredNinjaVersionForImplicitOuts().c_str());
}
bool cmGlobalNinjaGenerator::CheckLanguages(
std::vector<std::string> const& languages, cmMakefile* mf) const
{
@ -1311,16 +1324,12 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const
bool cmGlobalNinjaGenerator::SupportsConsolePool() const
{
return !cmSystemTools::VersionCompare(
cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
RequiredNinjaVersionForConsolePool().c_str());
return this->NinjaSupportsConsolePool;
}
bool cmGlobalNinjaGenerator::SupportsImplicitOuts() const
{
return !cmSystemTools::VersionCompare(
cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
this->RequiredNinjaVersionForImplicitOuts().c_str());
return this->NinjaSupportsImplicitOuts;
}
void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)

View File

@ -355,6 +355,7 @@ protected:
private:
std::string GetEditCacheCommand() const CM_OVERRIDE;
void FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
void CheckNinjaFeatures();
bool CheckLanguages(std::vector<std::string> const& languages,
cmMakefile* mf) const CM_OVERRIDE;
@ -441,6 +442,8 @@ private:
std::string NinjaCommand;
std::string NinjaVersion;
bool NinjaSupportsConsolePool;
bool NinjaSupportsImplicitOuts;
private:
void InitOutputPathPrefix();