diff options
author | Brad King <brad.king@kitware.com> | 2015-08-10 13:13:24 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-08-10 13:13:24 (GMT) |
commit | 2f16e608436193f465d4bac181db36464fa88e22 (patch) | |
tree | 189845f5e866d08abe921c0e79670a434d70dfe1 | |
parent | 815a2c09d3651c86e954e5626b573054add23ab3 (diff) | |
parent | 874e70bc57f54e5fc898a169797a0b1e45df31f6 (diff) | |
download | CMake-2f16e608436193f465d4bac181db36464fa88e22.zip CMake-2f16e608436193f465d4bac181db36464fa88e22.tar.gz CMake-2f16e608436193f465d4bac181db36464fa88e22.tar.bz2 |
Merge topic 'ninja-version-handling'
874e70bc Ninja: Prevent generating if installed Ninja version is too old.
c5ac2b9d Ninja: Centralized required Ninja version numbers and comparisons.
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 19 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 12 |
3 files changed, 25 insertions, 12 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 088f0e1..b92ad32 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -547,6 +547,18 @@ void cmGlobalNinjaGenerator // Source/cmake.cxx void cmGlobalNinjaGenerator::Generate() { + // Check minimum Ninja version. + if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, + CurrentNinjaVersion().c_str(), + RequiredNinjaVersion().c_str())) + { + std::ostringstream msg; + msg << "The detected version of Ninja (" << this->CurrentNinjaVersion(); + msg << ") is less than the version of Ninja required by CMake ("; + msg << this->RequiredNinjaVersion() << ")."; + this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str()); + return; + } this->OpenBuildFileStream(); this->OpenRulesFileStream(); @@ -1256,7 +1268,7 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const return "ninja"; } -std::string cmGlobalNinjaGenerator::ninjaVersion() const +std::string cmGlobalNinjaGenerator::CurrentNinjaVersion() const { std::string version; std::string command = ninjaCmd() + " --version"; @@ -1264,13 +1276,14 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const &version, 0, 0, 0, cmSystemTools::OUTPUT_NONE); - return version; + return cmSystemTools::TrimWhitespace(version); } bool cmGlobalNinjaGenerator::SupportsConsolePool() const { return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - ninjaVersion().c_str(), "1.5") == false; + CurrentNinjaVersion().c_str(), + RequiredNinjaVersionForConsolePool().c_str()) == false; } void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..a1df1c2 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -299,8 +299,10 @@ public: virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; - std::string ninjaVersion() const; - + std::string CurrentNinjaVersion() const; + // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 + static std::string RequiredNinjaVersion() { return "1.3"; } + static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; } bool SupportsConsolePool() const; protected: diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..aaad075 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -193,16 +193,14 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os) { // Default required version - // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 - std::string requiredVersion = "1.3"; + std::string requiredVersion = + this->GetGlobalNinjaGenerator()->RequiredNinjaVersion(); // Ninja generator uses the 'console' pool if available (>= 1.5) - std::string usedVersion = this->GetGlobalNinjaGenerator()->ninjaVersion(); - if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - usedVersion.c_str(), - "1.5") == false) + if(this->GetGlobalNinjaGenerator()->SupportsConsolePool()) { - requiredVersion = "1.5"; + requiredVersion = + this->GetGlobalNinjaGenerator()->RequiredNinjaVersionForConsolePool(); } cmGlobalNinjaGenerator::WriteComment(os, |