Explorar el Código

cmEnableLanguageCommand: Port away from cmCommand

Ref: #19499
Regina Pfeifer hace 6 años
padre
commit
28cf1271ed
Se han modificado 3 ficheros con 11 adiciones y 41 borrados
  1. 1 2
      Source/cmCommands.cxx
  2. 8 9
      Source/cmEnableLanguageCommand.cxx
  3. 2 30
      Source/cmEnableLanguageCommand.h

+ 1 - 2
Source/cmCommands.cxx

@@ -225,8 +225,7 @@ void GetProjectCommands(cmState* state)
   state->AddBuiltinCommand("build_command", cmBuildCommand);
   state->AddBuiltinCommand("create_test_sourcelist", cmCreateTestSourceList);
   state->AddBuiltinCommand("define_property", cmDefinePropertyCommand);
-  state->AddBuiltinCommand("enable_language",
-                           cm::make_unique<cmEnableLanguageCommand>());
+  state->AddBuiltinCommand("enable_language", cmEnableLanguageCommand);
   state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand);
   state->AddBuiltinCommand("get_source_file_property",
                            cm::make_unique<cmGetSourceFilePropertyCommand>());

+ 8 - 9
Source/cmEnableLanguageCommand.cxx

@@ -2,20 +2,19 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmEnableLanguageCommand.h"
 
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 
-class cmExecutionStatus;
-
-// cmEnableLanguageCommand
-bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args,
-                                          cmExecutionStatus&)
+bool cmEnableLanguageCommand(std::vector<std::string> const& args,
+                             cmExecutionStatus& status)
 {
-  bool optional = false;
-  std::vector<std::string> languages;
   if (args.empty()) {
-    this->SetError("called with incorrect number of arguments");
+    status.SetError("called with incorrect number of arguments");
     return false;
   }
+
+  bool optional = false;
+  std::vector<std::string> languages;
   for (std::string const& it : args) {
     if (it == "OPTIONAL") {
       optional = true;
@@ -24,6 +23,6 @@ bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args,
     }
   }
 
-  this->Makefile->EnableLanguage(languages, optional);
+  status.GetMakefile().EnableLanguage(languages, optional);
   return true;
 }

+ 2 - 30
Source/cmEnableLanguageCommand.h

@@ -8,37 +8,9 @@
 #include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
 class cmExecutionStatus;
 
-/** \class cmEnableLanguageCommand
- * \brief Specify the name for this build project.
- *
- * cmEnableLanguageCommand is used to specify a name for this build project.
- * It is defined once per set of CMakeList.txt files (including
- * all subdirectories). Currently it just sets the name of the workspace
- * file for Microsoft Visual C++
- */
-class cmEnableLanguageCommand : public cmCommand
-{
-public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmEnableLanguageCommand>();
-  }
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
-  bool InitialPass(std::vector<std::string> const& args,
-                   cmExecutionStatus& status) override;
-};
+bool cmEnableLanguageCommand(std::vector<std::string> const& args,
+                             cmExecutionStatus& status);
 
 #endif