From 0488ae63ea8dfa8ac455e36b7cc41e81620a080f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 Sep 2016 14:22:41 -0400 Subject: 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. --- Source/cmGlobalNinjaGenerator.cxx | 21 +++++++++++++++------ Source/cmGlobalNinjaGenerator.h | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 8146ea5..77693fe 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -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 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) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ac7a6b1..5c7d8fa 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -355,6 +355,7 @@ protected: private: std::string GetEditCacheCommand() const CM_OVERRIDE; void FindMakeProgram(cmMakefile* mf) CM_OVERRIDE; + void CheckNinjaFeatures(); bool CheckLanguages(std::vector 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(); -- cgit v0.12