diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2021-06-27 06:45:26 +0900 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-06-29 11:07:14 -0400 |
commit | 7cb4ad7e3990c879088b7573d136509989ed3f5b (patch) | |
tree | a3cc9052669cd23ef851b42664f8e7e306616bef /Source | |
parent | 23af78bb78b924b52b180049eb2ce62a4339251e (diff) | |
download | cmake-7cb4ad7e3990c879088b7573d136509989ed3f5b.tar.gz |
cmGlobalCommonGenerator: Adopt GetEditCacheCommand
Move the implementation from the Makefile generator so it can be
later used by the Ninja generator too.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalCommonGenerator.cxx | 34 | ||||
-rw-r--r-- | Source/cmGlobalCommonGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmGlobalUnixMakefileGenerator3.cxx | 30 | ||||
-rw-r--r-- | Source/cmGlobalUnixMakefileGenerator3.h | 1 |
4 files changed, 33 insertions, 33 deletions
diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx index 9e5bbca003..a4112db7dc 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 c641240f3d..fed9ce81b1 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 9c3de1eed6..d9f94a12ce 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 3073f72ffb..94ee47633b 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, std::set<cmGeneratorTarget const*>, cmStateSnapshot::StrictWeakOrder> |