From 7abddcab08c98a62e5386297124946b6483569ca Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 20 Jan 2023 09:38:43 -0500 Subject: Ninja: require Ninja 1.11 for C++ module support See: https://gitlab.kitware.com/cmake/cmake/-/issues/18355#note_1296721 See: https://github.com/ninja-build/ninja/pull/1937 --- Source/cmGlobalNinjaGenerator.cxx | 21 +++++++++++++-------- Source/cmGlobalNinjaGenerator.h | 6 ++++-- .../RunCMake/CXXModules/NoDyndepSupport-stderr.txt | 2 +- Tests/RunCMake/CXXModules/RunCMakeTest.cmake | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index a1eadb9..b80a06e 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -742,10 +742,13 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() this->NinjaSupportsMultilineDepfile = !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, RequiredNinjaVersionForMultilineDepfile()); - this->NinjaSupportsDyndeps = + this->NinjaSupportsDyndepsCxx = !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, - RequiredNinjaVersionForDyndeps()); - if (!this->NinjaSupportsDyndeps) { + RequiredNinjaVersionForDyndepsCxx()); + this->NinjaSupportsDyndepsFortran = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForDyndepsFortran()); + if (!this->NinjaSupportsDyndepsFortran) { // The ninja version number is not new enough to have upstream support. // Our ninja branch adds ".dyndep-#" to its version number, // where '#' is a feature-specific version number. Extract it. @@ -756,7 +759,7 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() unsigned long dyndep = 0; cmStrToULong(fv, &dyndep); if (dyndep == 1) { - this->NinjaSupportsDyndeps = true; + this->NinjaSupportsDyndepsFortran = true; } } } @@ -856,7 +859,7 @@ bool cmGlobalNinjaGenerator::CheckLanguages( bool cmGlobalNinjaGenerator::CheckCxxModuleSupport() { this->CxxModuleSupportCheck(); - if (this->NinjaSupportsDyndeps) { + if (this->NinjaSupportsDyndepsCxx) { return true; } bool const diagnose = !this->DiagnosedCxxModuleNinjaSupport && @@ -869,7 +872,8 @@ bool cmGlobalNinjaGenerator::CheckCxxModuleSupport() "using Ninja version \n" " " << this->NinjaVersion << "\n" "due to lack of required features. " - "Ninja " << RequiredNinjaVersionForDyndeps() << " or higher is required." + "Ninja " << RequiredNinjaVersionForDyndepsCxx() << + " or higher is required." ; /* clang-format on */ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str()); @@ -880,7 +884,7 @@ bool cmGlobalNinjaGenerator::CheckCxxModuleSupport() bool cmGlobalNinjaGenerator::CheckFortran(cmMakefile* mf) const { - if (this->NinjaSupportsDyndeps) { + if (this->NinjaSupportsDyndepsFortran) { return true; } @@ -890,7 +894,8 @@ bool cmGlobalNinjaGenerator::CheckFortran(cmMakefile* mf) const "The Ninja generator does not support Fortran using Ninja version\n" " " << this->NinjaVersion << "\n" "due to lack of required features. " - "Ninja " << RequiredNinjaVersionForDyndeps() << " or higher is required." + "Ninja " << RequiredNinjaVersionForDyndepsFortran() << + " or higher is required." ; /* clang-format on */ mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2b6d1cd..1436c83 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -389,7 +389,8 @@ public: { return "1.9"; } - static std::string RequiredNinjaVersionForDyndeps() { return "1.10"; } + static std::string RequiredNinjaVersionForDyndepsCxx() { return "1.11"; } + static std::string RequiredNinjaVersionForDyndepsFortran() { return "1.10"; } static std::string RequiredNinjaVersionForRestatTool() { return "1.10"; } static std::string RequiredNinjaVersionForUnconditionalRecompactTool() { @@ -578,7 +579,8 @@ private: bool NinjaSupportsImplicitOuts = false; bool NinjaSupportsManifestRestat = false; bool NinjaSupportsMultilineDepfile = false; - bool NinjaSupportsDyndeps = false; + bool NinjaSupportsDyndepsCxx = false; + bool NinjaSupportsDyndepsFortran = false; bool NinjaSupportsRestatTool = false; bool NinjaSupportsUnconditionalRecompactTool = false; bool NinjaSupportsMultipleOutputs = false; diff --git a/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt b/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt index 2bee19f..a0b2572 100644 --- a/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt +++ b/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt @@ -15,7 +15,7 @@ CMake Error: .* - due to lack of required features. Ninja 1.10 or higher is required. + due to lack of required features. Ninja 1.11 or higher is required. |CMake Error in CMakeLists.txt: The "nodyndep" target contains C\+\+ module sources which are not supported diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 01d59f8..78afd5e 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -38,7 +38,7 @@ endif () set(generator_supports_cxx_modules 0) if (RunCMake_GENERATOR MATCHES "Ninja" AND - ninja_version VERSION_GREATER_EQUAL "1.10" AND + ninja_version VERSION_GREATER_EQUAL "1.11" AND "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) set(generator_supports_cxx_modules 1) endif () -- cgit v0.12