From 61a737b088717201c331b83bd8794149e5d112e5 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 29 Jun 2021 11:27:07 +0900 Subject: cmGlobalNinjaGenerator: Rename SupportsConsolePool to SupportsDirectConsole Use a name that is not ninja-specific. --- Source/cmGlobalNinjaGenerator.cxx | 6 +++--- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmLocalNinjaGenerator.cxx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 963118f..bfc50c8 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -382,7 +382,7 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( if (restat) { vars["restat"] = "1"; } - if (uses_terminal && this->SupportsConsolePool()) { + if (uses_terminal && this->SupportsDirectConsole()) { vars["pool"] = "console"; } else if (!job_pool.empty()) { vars["pool"] = job_pool; @@ -1847,7 +1847,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) // Use 'console' pool to get non buffered output of the CMake re-run call // Available since Ninja 1.5 - if (this->SupportsConsolePool()) { + if (this->SupportsDirectConsole()) { reBuild.Variables["pool"] = "console"; } @@ -1941,7 +1941,7 @@ std::string cmGlobalNinjaGenerator::NinjaCmd() const return "ninja"; } -bool cmGlobalNinjaGenerator::SupportsConsolePool() const +bool cmGlobalNinjaGenerator::SupportsDirectConsole() const { return this->NinjaSupportsConsolePool; } diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index bb4ce2b..9aa1152 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -406,7 +406,7 @@ public: return "1.10.2"; } static std::string RequiredNinjaVersionForCodePage() { return "1.11"; } - bool SupportsConsolePool() const; + bool SupportsDirectConsole() const; bool SupportsImplicitOuts() const; bool SupportsManifestRestat() const; bool SupportsMultilineDepfile() const; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 7f7b1e7..9f8e7ed 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -279,7 +279,7 @@ void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os) std::string requiredVersion = cmGlobalNinjaGenerator::RequiredNinjaVersion(); // Ninja generator uses the 'console' pool if available (>= 1.5) - if (this->GetGlobalNinjaGenerator()->SupportsConsolePool()) { + if (this->GetGlobalNinjaGenerator()->SupportsDirectConsole()) { requiredVersion = cmGlobalNinjaGenerator::RequiredNinjaVersionForConsolePool(); } -- cgit v0.12 From 1db4d7462808e9af5e2a6de029943d51a521f52c Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 29 Jun 2021 11:27:07 +0900 Subject: cmGlobalCommonGenerator: Add SupportsDirectConsole Default to `true` since this is used by Makefile generators. The Ninja generator already overrides it to use a version check. --- Source/cmGlobalCommonGenerator.h | 3 +++ Source/cmGlobalNinjaGenerator.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalCommonGenerator.h b/Source/cmGlobalCommonGenerator.h index 2aa9d27..21cfd11 100644 --- a/Source/cmGlobalCommonGenerator.h +++ b/Source/cmGlobalCommonGenerator.h @@ -42,4 +42,7 @@ public: std::map ComputeDirectoryTargets() const; bool IsExcludedFromAllInConfig(const DirectoryTarget::Target& t, const std::string& config); + +protected: + virtual bool SupportsDirectConsole() const { return true; } }; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 9aa1152..ce47122 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -406,7 +406,7 @@ public: return "1.10.2"; } static std::string RequiredNinjaVersionForCodePage() { return "1.11"; } - bool SupportsDirectConsole() const; + bool SupportsDirectConsole() const override; bool SupportsImplicitOuts() const; bool SupportsManifestRestat() const; bool SupportsMultilineDepfile() const; -- cgit v0.12 From 23af78bb78b924b52b180049eb2ce62a4339251e Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sun, 27 Jun 2021 06:45:26 +0900 Subject: cmGlobalCommonGenerator: Adopt GetEditCacheTargetName The implementation is the same for both Makefile and Ninja generators. --- Source/cmGlobalCommonGenerator.h | 1 + Source/cmGlobalNinjaGenerator.h | 1 - Source/cmGlobalUnixMakefileGenerator3.h | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmGlobalCommonGenerator.h b/Source/cmGlobalCommonGenerator.h index 21cfd11..c641240 100644 --- a/Source/cmGlobalCommonGenerator.h +++ b/Source/cmGlobalCommonGenerator.h @@ -45,4 +45,5 @@ public: protected: virtual bool SupportsDirectConsole() const { return true; } + const char* GetEditCacheTargetName() const override { return "edit_cache"; } }; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ce47122..519be3f 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -220,7 +220,6 @@ public: { return "package_source"; } - const char* GetEditCacheTargetName() const override { return "edit_cache"; } const char* GetRebuildCacheTargetName() const override { return "rebuild_cache"; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 7c950cc..3073f72 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -228,7 +228,6 @@ protected: { return "package_source"; } - const char* GetEditCacheTargetName() const override { return "edit_cache"; } const char* GetRebuildCacheTargetName() const override { return "rebuild_cache"; -- cgit v0.12 From 7cb4ad7e3990c879088b7573d136509989ed3f5b Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sun, 27 Jun 2021 06:45:26 +0900 Subject: cmGlobalCommonGenerator: Adopt GetEditCacheCommand Move the implementation from the Makefile generator so it can be later used by the Ninja generator too. --- Source/cmGlobalCommonGenerator.cxx | 34 +++++++++++++++++++++++++++++-- Source/cmGlobalCommonGenerator.h | 1 + Source/cmGlobalUnixMakefileGenerator3.cxx | 30 --------------------------- Source/cmGlobalUnixMakefileGenerator3.h | 1 - 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx index 9e5bbca..a4112db 100644 --- a/Source/cmGlobalCommonGenerator.cxx +++ b/Source/cmGlobalCommonGenerator.cxx @@ -16,8 +16,8 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" - -class cmake; +#include "cmSystemTools.h" +#include "cmake.h" cmGlobalCommonGenerator::cmGlobalCommonGenerator(cmake* cm) : cmGlobalGenerator(cm) @@ -95,3 +95,33 @@ bool cmGlobalCommonGenerator::IsExcludedFromAllInConfig( } return !t.ExcludedFromAllInConfigs.empty(); } + +std::string cmGlobalCommonGenerator::GetEditCacheCommand() const +{ + // If generating for an extra IDE, the edit_cache target cannot + // launch a terminal-interactive tool, so always use cmake-gui. + if (!this->GetExtraGeneratorName().empty()) { + return cmSystemTools::GetCMakeGUICommand(); + } + + // Use an internal cache entry to track the latest dialog used + // to edit the cache, and use that for the edit_cache target. + cmake* cm = this->GetCMakeInstance(); + std::string editCacheCommand = cm->GetCMakeEditCommand(); + if (!cm->GetCacheDefinition("CMAKE_EDIT_COMMAND") || + !editCacheCommand.empty()) { + if (editCacheCommand.empty()) { + editCacheCommand = cmSystemTools::GetCMakeCursesCommand(); + } + if (editCacheCommand.empty()) { + editCacheCommand = cmSystemTools::GetCMakeGUICommand(); + } + if (!editCacheCommand.empty()) { + cm->AddCacheEntry("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), + "Path to cache edit program executable.", + cmStateEnums::INTERNAL); + } + } + cmProp edit_cmd = cm->GetCacheDefinition("CMAKE_EDIT_COMMAND"); + return edit_cmd ? *edit_cmd : std::string(); +} diff --git a/Source/cmGlobalCommonGenerator.h b/Source/cmGlobalCommonGenerator.h index c641240..fed9ce8 100644 --- a/Source/cmGlobalCommonGenerator.h +++ b/Source/cmGlobalCommonGenerator.h @@ -46,4 +46,5 @@ public: protected: virtual bool SupportsDirectConsole() const { return true; } const char* GetEditCacheTargetName() const override { return "edit_cache"; } + std::string GetEditCacheCommand() const override; }; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 9c3de1e..d9f94a1 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -78,36 +78,6 @@ void cmGlobalUnixMakefileGenerator3::GetDocumentation( entry.Brief = "Generates standard UNIX makefiles."; } -std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const -{ - // If generating for an extra IDE, the edit_cache target cannot - // launch a terminal-interactive tool, so always use cmake-gui. - if (!this->GetExtraGeneratorName().empty()) { - return cmSystemTools::GetCMakeGUICommand(); - } - - // Use an internal cache entry to track the latest dialog used - // to edit the cache, and use that for the edit_cache target. - cmake* cm = this->GetCMakeInstance(); - std::string editCacheCommand = cm->GetCMakeEditCommand(); - if (!cm->GetCacheDefinition("CMAKE_EDIT_COMMAND") || - !editCacheCommand.empty()) { - if (editCacheCommand.empty()) { - editCacheCommand = cmSystemTools::GetCMakeCursesCommand(); - } - if (editCacheCommand.empty()) { - editCacheCommand = cmSystemTools::GetCMakeGUICommand(); - } - if (!editCacheCommand.empty()) { - cm->AddCacheEntry("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), - "Path to cache edit program executable.", - cmStateEnums::INTERNAL); - } - } - cmProp edit_cmd = cm->GetCacheDefinition("CMAKE_EDIT_COMMAND"); - return edit_cmd ? *edit_cmd : std::string(); -} - void cmGlobalUnixMakefileGenerator3::ComputeTargetObjectDirectory( cmGeneratorTarget* gt) const { diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 3073f72..94ee476 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -277,7 +277,6 @@ protected: private: const char* GetBuildIgnoreErrorsFlag() const override { return "-i"; } - std::string GetEditCacheCommand() const override; std::map, cmStateSnapshot::StrictWeakOrder> -- cgit v0.12 From 51bf4094fb7c3bf82c6e51d8e6b55e0cc289e5a5 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Thu, 24 Jun 2021 22:13:08 +0900 Subject: Ninja: Use `ccmake` for `edit_cache` If `ninja` is new enough to support the console pool, and `ccmake` is available, use it for `edit_cache`. --- Help/release/dev/ninja-edit_cache.rst | 5 +++++ Source/cmGlobalCommonGenerator.cxx | 2 +- Source/cmGlobalNinjaGenerator.cxx | 7 ------- Source/cmGlobalNinjaGenerator.h | 1 - 4 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 Help/release/dev/ninja-edit_cache.rst diff --git a/Help/release/dev/ninja-edit_cache.rst b/Help/release/dev/ninja-edit_cache.rst new file mode 100644 index 0000000..9083f56 --- /dev/null +++ b/Help/release/dev/ninja-edit_cache.rst @@ -0,0 +1,5 @@ +ninja-edit_cache +---------------- + +* The :ref:`Ninja Generators` now implement the ``edit_cache`` target + using :manual:`ccmake(1)` if available. diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx index a4112db..a8e0f23 100644 --- a/Source/cmGlobalCommonGenerator.cxx +++ b/Source/cmGlobalCommonGenerator.cxx @@ -110,7 +110,7 @@ std::string cmGlobalCommonGenerator::GetEditCacheCommand() const std::string editCacheCommand = cm->GetCMakeEditCommand(); if (!cm->GetCacheDefinition("CMAKE_EDIT_COMMAND") || !editCacheCommand.empty()) { - if (editCacheCommand.empty()) { + if (this->SupportsDirectConsole() && editCacheCommand.empty()) { editCacheCommand = cmSystemTools::GetCMakeCursesCommand(); } if (editCacheCommand.empty()) { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index bfc50c8..2d36fd8 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1019,13 +1019,6 @@ bool cmGlobalNinjaGenerator::HasRule(const std::string& name) // Private virtual overrides -std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const -{ - // Ninja by design does not run interactive tools in the terminal, - // so our only choice is cmake-gui. - return cmSystemTools::GetCMakeGUICommand(); -} - void cmGlobalNinjaGenerator::ComputeTargetObjectDirectory( cmGeneratorTarget* gt) const { diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 519be3f..ec73475 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -488,7 +488,6 @@ protected: std::string DefaultFileConfig; private: - std::string GetEditCacheCommand() const override; bool FindMakeProgram(cmMakefile* mf) override; void CheckNinjaFeatures(); void CheckNinjaCodePage(); -- cgit v0.12