From fd58bb83e6a6dcbe27afd2272d1a9c2722de2482 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 30 Jul 2019 13:53:34 -0400 Subject: Ninja: Use in-class initialization of global generator members --- Source/cmGlobalNinjaGenerator.cxx | 8 -------- Source/cmGlobalNinjaGenerator.h | 16 ++++++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index bad715d..87c55bf 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -415,14 +415,6 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os, cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) : cmGlobalCommonGenerator(cm) - , UsingGCCOnWindows(false) - , ComputingUnknownDependencies(false) - , PolicyCMP0058(cmPolicies::WARN) - , NinjaSupportsConsolePool(false) - , NinjaSupportsImplicitOuts(false) - , NinjaSupportsManifestRestat(false) - , NinjaSupportsMultilineDepfile(false) - , NinjaSupportsDyndeps(0) { #ifdef _WIN32 cm->GetState()->SetWindowsShell(true); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 99afc1d..9ca7480 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -402,7 +402,7 @@ private: /// The set of dependencies to add to the "all" target. cmNinjaDeps AllDependencies; - bool UsingGCCOnWindows; + bool UsingGCCOnWindows = false; /// The set of custom commands we have seen. std::set CustomCommands; @@ -412,8 +412,8 @@ private: /// Whether we are collecting known build outputs and needed /// dependencies to determine unknown dependencies. - bool ComputingUnknownDependencies; - cmPolicies::PolicyStatus PolicyCMP0058; + bool ComputingUnknownDependencies = false; + cmPolicies::PolicyStatus PolicyCMP0058 = cmPolicies::WARN; /// The combined explicit dependencies of custom build commands std::set CombinedCustomCommandExplicitDependencies; @@ -435,11 +435,11 @@ private: std::string NinjaCommand; std::string NinjaVersion; - bool NinjaSupportsConsolePool; - bool NinjaSupportsImplicitOuts; - bool NinjaSupportsManifestRestat; - bool NinjaSupportsMultilineDepfile; - unsigned long NinjaSupportsDyndeps; + bool NinjaSupportsConsolePool = false; + bool NinjaSupportsImplicitOuts = false; + bool NinjaSupportsManifestRestat = false; + bool NinjaSupportsMultilineDepfile = false; + unsigned long NinjaSupportsDyndeps = 0; private: void InitOutputPathPrefix(); -- cgit v0.12 From 83368b4dd539f287942e26e53ed49d4ec3a18db0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 30 Jul 2019 13:53:41 -0400 Subject: Ninja: Drop unused dyndep version check Our dyndep support version 1 has been merged to upstream Ninja. We never developed a second dyndep version, so simply drop our checks for different versions. --- Source/cmGlobalNinjaGenerator.cxx | 47 ++++++++++++++++----------------------- Source/cmGlobalNinjaGenerator.h | 2 +- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 87c55bf..4656d03 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -555,7 +555,11 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() std::string::size_type pos = this->NinjaVersion.find(k_DYNDEP_); if (pos != std::string::npos) { const char* fv = &this->NinjaVersion[pos + k_DYNDEP_.size()]; - cmSystemTools::StringToULong(fv, &this->NinjaSupportsDyndeps); + unsigned long dyndep = 0; + cmSystemTools::StringToULong(fv, &dyndep); + if (dyndep == 1) { + this->NinjaSupportsDyndeps = true; + } } } } @@ -572,37 +576,24 @@ bool cmGlobalNinjaGenerator::CheckLanguages( bool cmGlobalNinjaGenerator::CheckFortran(cmMakefile* mf) const { - if (this->NinjaSupportsDyndeps == 1) { + if (this->NinjaSupportsDyndeps) { return true; } std::ostringstream e; - if (this->NinjaSupportsDyndeps == 0) { - /* clang-format off */ - e << - "The Ninja generator does not support Fortran using Ninja version\n" - " " + this->NinjaVersion + "\n" - "due to lack of required features. " - "Kitware has implemented the required features but as of this version " - "of CMake they have not been integrated to upstream ninja. " - "Pending integration, Kitware maintains a branch at:\n" - " https://github.com/Kitware/ninja/tree/features-for-fortran#readme\n" - "with the required features. " - "One may build ninja from that branch to get support for Fortran." - ; - /* clang-format on */ - } else { - /* clang-format off */ - e << - "The Ninja generator in this version of CMake does not support Fortran " - "using Ninja version\n" - " " + this->NinjaVersion + "\n" - "because its 'dyndep' feature version is " << - this->NinjaSupportsDyndeps << ". " - "This version of CMake is aware only of 'dyndep' feature version 1." - ; - /* clang-format on */ - } + /* clang-format off */ + e << + "The Ninja generator does not support Fortran using Ninja version\n" + " " + this->NinjaVersion + "\n" + "due to lack of required features. " + "Kitware has implemented the required features but as of this version " + "of CMake they have not been integrated to upstream ninja. " + "Pending integration, Kitware maintains a branch at:\n" + " https://github.com/Kitware/ninja/tree/features-for-fortran#readme\n" + "with the required features. " + "One may build ninja from that branch to get support for Fortran." + ; + /* clang-format on */ mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccured(); return false; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 9ca7480..c752bab 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -439,7 +439,7 @@ private: bool NinjaSupportsImplicitOuts = false; bool NinjaSupportsManifestRestat = false; bool NinjaSupportsMultilineDepfile = false; - unsigned long NinjaSupportsDyndeps = 0; + bool NinjaSupportsDyndeps = false; private: void InitOutputPathPrefix(); -- cgit v0.12 From c81a86ee6d69bbae9f0213765aabc434faf10080 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 30 Jul 2019 13:53:44 -0400 Subject: Ninja: Record dyndep support by Ninja 1.10 Upstream Ninja 1.10 and above support the `dyndep` feature we need for Fortran. --- Source/cmGlobalNinjaGenerator.cxx | 13 +++++++++---- Source/cmGlobalNinjaGenerator.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 4656d03..0b68966 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -548,7 +548,11 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() this->NinjaSupportsMultilineDepfile = !cmSystemTools::VersionCompare( cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), RequiredNinjaVersionForMultilineDepfile().c_str()); - { + this->NinjaSupportsDyndeps = !cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), + RequiredNinjaVersionForDyndeps().c_str()); + if (!this->NinjaSupportsDyndeps) { + // 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. static std::string const k_DYNDEP_ = ".dyndep-"; @@ -586,9 +590,10 @@ 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. " - "Kitware has implemented the required features but as of this version " - "of CMake they have not been integrated to upstream ninja. " - "Pending integration, Kitware maintains a branch at:\n" + "Kitware has implemented the required features and they have been " + "merged to upstream ninja for inclusion in Ninja 1.10 and higher. " + "As of this version of CMake, Ninja 1.10 has not been released. " + "Meanwhile, Kitware maintains a branch of Ninja at:\n" " https://github.com/Kitware/ninja/tree/features-for-fortran#readme\n" "with the required features. " "One may build ninja from that branch to get support for Fortran." diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index c752bab..db64031 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -322,6 +322,7 @@ public: { return "1.9"; } + static std::string RequiredNinjaVersionForDyndeps() { return "1.10"; } bool SupportsConsolePool() const; bool SupportsImplicitOuts() const; bool SupportsManifestRestat() const; -- cgit v0.12