Răsfoiți Sursa

cmake: Clarify name of enum identifying set of commands added

Brad King 1 lună în urmă
părinte
comite
9e36f22684

+ 1 - 1
Source/CPack/cmCPackGenerator.cxx

@@ -760,7 +760,7 @@ int cmCPackGenerator::InstallCMakeProject(
                   "-   Install component: " << component << std::endl);
   }
 
-  cmake cm(cmake::RoleScript, cmState::CPack);
+  cmake cm(cmake::CommandSet::Script, cmState::CPack);
   cm.GetCurrentSnapshot().SetDefaultDefinitions();
   cm.AddCMakePaths();
   cm.SetProgressCallback([this](std::string const& msg, float prog) {

+ 1 - 1
Source/CPack/cpack.cxx

@@ -225,7 +225,7 @@ int main(int argc, char const* const* argv)
                      } },
   };
 
-  cmake cminst(cmake::RoleScript, cmState::CPack);
+  cmake cminst(cmake::CommandSet::Script, cmState::CPack);
   cminst.SetProgressCallback(cpackProgressCallback);
   cminst.GetCurrentSnapshot().SetDefaultDefinitions();
   cmGlobalGenerator cmgg(&cminst);

+ 1 - 1
Source/CTest/cmCTestBuildAndTest.cxx

@@ -177,7 +177,7 @@ int cmCTestBuildAndTest::Run()
     return 1;
   }
 
-  cmake cm(cmake::RoleProject, cmState::Project);
+  cmake cm(cmake::CommandSet::Project, cmState::Project);
   cmCTestBuildAndTestCaptureRAII captureRAII(cm);
   static_cast<void>(captureRAII);
 

+ 1 - 1
Source/CTest/cmCTestLaunch.cxx

@@ -405,7 +405,7 @@ int cmCTestLaunch::Main(int argc, char const* const argv[], Op operation)
 
 void cmCTestLaunch::LoadConfig()
 {
-  cmake cm(cmake::RoleScript, cmState::CTest);
+  cmake cm(cmake::CommandSet::Script, cmState::CTest);
   cm.GetCurrentSnapshot().SetDefaultDefinitions();
   cmGlobalGenerator gg(&cm);
   cmMakefile mf(&gg, cm.GetCurrentSnapshot());

+ 2 - 1
Source/CTest/cmCTestScriptHandler.cxx

@@ -172,7 +172,8 @@ int cmCTestScriptHandler::ExecuteScript(std::string const& total_script_arg)
 void cmCTestScriptHandler::CreateCMake()
 {
   // create a cmake instance to read the configuration script
-  this->CMake = cm::make_unique<cmake>(cmake::RoleScript, cmState::CTest);
+  this->CMake =
+    cm::make_unique<cmake>(cmake::CommandSet::Script, cmState::CTest);
   this->CMake->GetCurrentSnapshot().SetDefaultDefinitions();
   this->CMake->AddCMakePaths();
   this->CMake->SetWorkingMode(cmake::SCRIPT_MODE,

+ 1 - 1
Source/CTest/cmCTestTestHandler.cxx

@@ -1754,7 +1754,7 @@ bool cmCTestTestHandler::GetListOfTests()
   }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                      "Constructing a list of tests" << std::endl, this->Quiet);
-  cmake cm(cmake::RoleScript, cmState::CTest);
+  cmake cm(cmake::CommandSet::Script, cmState::CTest);
   cm.GetCurrentSnapshot().SetDefaultDefinitions();
   cmGlobalGenerator gg(&cm);
   cmMakefile mf(&gg, cm.GetCurrentSnapshot());

+ 1 - 1
Source/CursesDialog/ccmake.cxx

@@ -75,7 +75,7 @@ int main(int argc, char const* const* argv)
   cmDocumentation doc;
   doc.addCMakeStandardDocSections();
   if (doc.CheckOptions(argc, argv)) {
-    cmake hcm(cmake::RoleInternal, cmState::Help);
+    cmake hcm(cmake::CommandSet::None, cmState::Help);
     hcm.AddCMakePaths();
     auto generators = hcm.GetGeneratorsDocumentation();
     doc.SetName("ccmake");

+ 1 - 1
Source/CursesDialog/cmCursesMainForm.cxx

@@ -40,7 +40,7 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
   this->HelpMessage.emplace_back();
   this->HelpMessage.emplace_back(s_ConstHelpMessage);
   this->CMakeInstance =
-    cm::make_unique<cmake>(cmake::RoleProject, cmState::Project);
+    cm::make_unique<cmake>(cmake::CommandSet::Project, cmState::Project);
   this->CMakeInstance->SetCMakeEditCommand(
     cmSystemTools::GetCMakeCursesCommand());
 

+ 1 - 1
Source/QtDialog/CMakeSetup.cxx

@@ -82,7 +82,7 @@ int main(int argc, char** argv)
   doc.addCMakeStandardDocSections();
   if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) {
     // Construct and print requested documentation.
-    cmake hcm(cmake::RoleInternal, cmState::Help);
+    cmake hcm(cmake::CommandSet::None, cmState::Help);
     hcm.AddCMakePaths();
 
     auto generators = hcm.GetGeneratorsDocumentation();

+ 1 - 1
Source/QtDialog/QCMake.cxx

@@ -47,7 +47,7 @@ QCMake::QCMake(QObject* p)
     [this](std::string const& msg) { this->stderrCallback(msg); });
 
   this->CMakeInstance =
-    cm::make_unique<cmake>(cmake::RoleProject, cmState::Project);
+    cm::make_unique<cmake>(cmake::CommandSet::Project, cmState::Project);
   this->CMakeInstance->SetCMakeEditCommand(
     cmSystemTools::GetCMakeGUICommand());
   this->CMakeInstance->SetProgressCallback(

+ 1 - 1
Source/cmCTest.cxx

@@ -2656,7 +2656,7 @@ int cmCTest::ExecuteTests(std::vector<std::string> const& args)
   cmCTestTestHandler handler(this);
 
   {
-    cmake cm(cmake::RoleScript, cmState::CTest);
+    cmake cm(cmake::CommandSet::Script, cmState::CTest);
     cm.GetCurrentSnapshot().SetDefaultDefinitions();
     cmGlobalGenerator gg(&cm);
     cmMakefile mf(&gg, cm.GetCurrentSnapshot());

+ 1 - 1
Source/cmGlobalNinjaGenerator.cxx

@@ -3049,7 +3049,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
 
   auto export_info = cmDyndepCollation::ParseExportInfo(tdi);
 
-  cmake cm(cmake::RoleInternal, cmState::Unknown);
+  cmake cm(cmake::CommandSet::None, cmState::Unknown);
   cm.SetHomeDirectory(dir_top_src);
   cm.SetHomeOutputDirectory(dir_top_bld);
   auto ggd = cm.CreateGlobalGenerator("Ninja");

+ 1 - 1
Source/cmGraphVizWriter.cxx

@@ -195,7 +195,7 @@ void cmGraphVizWriter::ReadSettings(
   std::string const& settingsFileName,
   std::string const& fallbackSettingsFileName)
 {
-  cmake cm(cmake::RoleScript, cmState::Unknown);
+  cmake cm(cmake::CommandSet::Script, cmState::Unknown);
   cm.GetCurrentSnapshot().SetDefaultDefinitions();
   cmGlobalGenerator ggi(&cm);
   cmMakefile mf(&ggi, cm.GetCurrentSnapshot());

+ 2 - 1
Source/cmMakefile.cxx

@@ -3251,7 +3251,8 @@ int cmMakefile::TryCompile(std::string const& srcdir,
   // make sure the same generator is used
   // use this program as the cmake to be run, it should not
   // be run that way but the cmake object requires a valid path
-  cmake cm(cmake::RoleProject, cmState::Project, cmState::TryCompile::Yes);
+  cmake cm(cmake::CommandSet::Project, cmState::Project,
+           cmState::TryCompile::Yes);
   auto gg = cm.CreateGlobalGenerator(this->GetGlobalGenerator()->GetName());
   if (!gg) {
     this->IssueMessage(MessageType::INTERNAL_ERROR,

+ 5 - 4
Source/cmake.cxx

@@ -297,7 +297,8 @@ cmDocumentationEntry cmake::CMAKE_STANDARD_OPTIONS_TABLE[19] = {
     "not errors." }
 };
 
-cmake::cmake(Role role, cmState::Mode mode, cmState::TryCompile isTryCompile)
+cmake::cmake(CommandSet commandSet, cmState::Mode mode,
+             cmState::TryCompile isTryCompile)
   : CMakeWorkingDirectory(cmSystemTools::GetLogicalWorkingDirectory())
   , FileTimeCache(cm::make_unique<cmFileTimeCache>())
 #ifndef CMAKE_BOOTSTRAP
@@ -321,10 +322,10 @@ cmake::cmake(Role role, cmState::Mode mode, cmState::TryCompile isTryCompile)
 
   this->AddDefaultGenerators();
   this->AddDefaultExtraGenerators();
-  if (role == RoleScript || role == RoleProject) {
+  if (commandSet == CommandSet::Script || commandSet == CommandSet::Project) {
     this->AddScriptingCommands();
   }
-  if (role == RoleProject) {
+  if (commandSet == CommandSet::Project) {
     this->AddProjectCommands();
   }
 
@@ -3476,7 +3477,7 @@ int cmake::CheckBuildSystem()
   // Read the rerun check file and use it to decide whether to do the
   // global generate.
   // Actually, all we need is the `set` command.
-  cmake cm(RoleScript, cmState::Unknown);
+  cmake cm(CommandSet::Script, cmState::Unknown);
   cm.GetCurrentSnapshot().SetDefaultDefinitions();
   cmGlobalGenerator gg(&cm);
   cmMakefile mf(&gg, cm.GetCurrentSnapshot());

+ 5 - 5
Source/cmake.h

@@ -86,11 +86,11 @@ struct cmGlobCacheEntry;
 class cmake
 {
 public:
-  enum Role
+  enum class CommandSet
   {
-    RoleInternal, // no commands
-    RoleScript,   // script commands
-    RoleProject   // all commands
+    None,    // no commands
+    Script,  // script commands
+    Project, // all commands
   };
 
   enum DiagLevel
@@ -171,7 +171,7 @@ public:
   static int const DEFAULT_BUILD_PARALLEL_LEVEL = 0;
 
   /// Default constructor
-  cmake(Role role, cmState::Mode mode,
+  cmake(CommandSet commandSet, cmState::Mode mode,
         cmState::TryCompile isTryCompile = cmState::TryCompile::No);
   /// Destructor
   ~cmake();

+ 10 - 9
Source/cmakemain.cxx

@@ -221,7 +221,7 @@ int do_cmake(int ac, char const* const* av)
   doc.addCMakeStandardDocSections();
   if (doc.CheckOptions(ac, av, "--")) {
     // Construct and print requested documentation.
-    cmake hcm(cmake::RoleInternal, cmState::Help);
+    cmake hcm(cmake::CommandSet::None, cmState::Help);
     hcm.AddCMakePaths();
 
     // the command line args are processed here so that you can do
@@ -359,12 +359,13 @@ int do_cmake(int ac, char const* const* av)
   }
 
   if (sysinfo) {
-    cmake cm(cmake::RoleProject, cmState::Project);
+    cmake cm(cmake::CommandSet::Project, cmState::Project);
     int ret = cm.GetSystemInformation(parsedArgs);
     return ret;
   }
-  cmake::Role const role =
-    workingMode == cmake::SCRIPT_MODE ? cmake::RoleScript : cmake::RoleProject;
+  cmake::CommandSet const commandSet = workingMode == cmake::SCRIPT_MODE
+    ? cmake::CommandSet::Script
+    : cmake::CommandSet::Project;
   cmState::Mode mode = cmState::Unknown;
   switch (workingMode) {
     case cmake::NORMAL_MODE:
@@ -381,7 +382,7 @@ int do_cmake(int ac, char const* const* av)
   auto const failurePolicy = workingMode == cmake::NORMAL_MODE
     ? cmake::CommandFailureAction::EXIT_CODE
     : cmake::CommandFailureAction::FATAL_ERROR;
-  cmake cm(role, mode);
+  cmake cm(commandSet, mode);
   cmSystemTools::SetMessageCallback(
     [&cm](std::string const& msg, cmMessageMetadata const& md) {
       cmakemainMessageCallback(msg, md, &cm);
@@ -679,7 +680,7 @@ int do_build(int ac, char const* const* av)
     return 1;
   }
 
-  cmake cm(cmake::RoleInternal, cmState::Project);
+  cmake cm(cmake::CommandSet::None, cmState::Project);
   cmSystemTools::SetMessageCallback(
     [&cm](std::string const& msg, cmMessageMetadata const& md) {
       cmakemainMessageCallback(msg, md, &cm);
@@ -961,7 +962,7 @@ int do_install(int ac, char const* const* av)
     } else {
       for (auto const& script : handler.GetScripts()) {
         std::vector<std::string> cmd = script.command;
-        cmake cm(cmake::RoleScript, cmState::Script);
+        cmake cm(cmake::CommandSet::Script, cmState::Script);
         cmSystemTools::SetMessageCallback(
           [&cm](std::string const& msg, cmMessageMetadata const& md) {
             cmakemainMessageCallback(msg, md, &cm);
@@ -1064,7 +1065,7 @@ int do_workflow(int ac, char const* const* av)
     return 1;
   }
 
-  cmake cm(cmake::RoleInternal, cmState::Project);
+  cmake cm(cmake::CommandSet::None, cmState::Project);
   cmSystemTools::SetMessageCallback(
     [&cm](std::string const& msg, cmMessageMetadata const& md) {
       cmakemainMessageCallback(msg, md, &cm);
@@ -1108,7 +1109,7 @@ int do_open(int ac, char const* const* av)
     return 1;
   }
 
-  cmake cm(cmake::RoleInternal, cmState::Unknown);
+  cmake cm(cmake::CommandSet::None, cmState::Unknown);
   cmSystemTools::SetMessageCallback(
     [&cm](std::string const& msg, cmMessageMetadata const& md) {
       cmakemainMessageCallback(msg, md, &cm);

+ 3 - 3
Source/cmcmd.cxx

@@ -1150,7 +1150,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
         std::cerr << "-E capabilities accepts no additional arguments\n";
         return 1;
       }
-      cmake cm(cmake::RoleInternal, cmState::Unknown);
+      cmake cm(cmake::CommandSet::None, cmState::Unknown);
       std::cout << cm.ReportCapabilities();
       return 0;
     }
@@ -1398,7 +1398,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
 
       // Create a cmake object instance to process dependencies.
       // All we need is the `set` command.
-      cmake cm(cmake::RoleScript, cmState::Unknown);
+      cmake cm(cmake::CommandSet::Script, cmState::Unknown);
       std::string gen;
       std::string homeDir;
       std::string startDir;
@@ -1752,7 +1752,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
       }
       // Create a cmake object instance to process dependencies.
       // All we need is the `set` command.
-      cmake cm(cmake::RoleScript, cmState::Unknown);
+      cmake cm(cmake::CommandSet::Script, cmState::Unknown);
       std::string homeDir;
       std::string startDir;
       std::string homeOutDir;

+ 3 - 3
Tests/CMakeLib/testDebuggerVariablesHelper.cxx

@@ -55,7 +55,7 @@ static Dummies CreateDummies(
 {
   Dummies dummies;
   dummies.CMake =
-    std::make_shared<cmake>(cmake::RoleProject, cmState::Project);
+    std::make_shared<cmake>(cmake::CommandSet::Project, cmState::Project);
   cmState* state = dummies.CMake->GetState();
   dummies.GlobalGenerator =
     std::make_shared<cmGlobalGenerator>(dummies.CMake.get());
@@ -501,7 +501,7 @@ static bool testCreateFromFileSet()
   auto variablesManager =
     std::make_shared<cmDebugger::cmDebuggerVariablesManager>();
 
-  cmake cm(cmake::RoleScript, cmState::Unknown);
+  cmake cm(cmake::CommandSet::Script, cmState::Unknown);
   cmFileSet fileSet(cm, "Foo", "HEADERS", cmFileSetVisibility::Public);
   BT<std::string> directory;
   directory.Value = "c:/";
@@ -545,7 +545,7 @@ static bool testCreateFromFileSets()
   auto variablesManager =
     std::make_shared<cmDebugger::cmDebuggerVariablesManager>();
 
-  cmake cm(cmake::RoleScript, cmState::Unknown);
+  cmake cm(cmake::CommandSet::Script, cmState::Unknown);
   cmFileSet fileSet(cm, "Foo", "HEADERS", cmFileSetVisibility::Public);
   BT<std::string> directory;
   directory.Value = "c:/";