cmGlobalCommonGenerator: Adopt GetEditCacheCommand

Move the implementation from the Makefile generator so it can be
later used by the Ninja generator too.
This commit is contained in:
NAKAMURA Takumi
2021-06-27 06:45:26 +09:00
committed by Brad King
parent 23af78bb78
commit 7cb4ad7e39
4 changed files with 33 additions and 33 deletions

View File

@@ -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();
}

View File

@@ -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;
};

View File

@@ -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
{

View File

@@ -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>