Selaa lähdekoodia

cmIncludeRegularExpressionCommand: Port away from cmCommand

Ref: #19499
Regina Pfeifer 6 vuotta sitten
vanhempi
sitoutus
242d876d7b

+ 2 - 3
Source/cmCommands.cxx

@@ -233,9 +233,8 @@ void GetProjectCommands(cmState* state)
   state->AddBuiltinCommand("get_test_property", cmGetTestPropertyCommand);
   state->AddBuiltinCommand("include_directories",
                            cm::make_unique<cmIncludeDirectoryCommand>());
-  state->AddBuiltinCommand(
-    "include_regular_expression",
-    cm::make_unique<cmIncludeRegularExpressionCommand>());
+  state->AddBuiltinCommand("include_regular_expression",
+                           cmIncludeRegularExpressionCommand);
   state->AddBuiltinCommand("install", cm::make_unique<cmInstallCommand>());
   state->AddBuiltinCommand("install_files",
                            cm::make_unique<cmInstallFilesCommand>());

+ 9 - 9
Source/cmIncludeRegularExpressionCommand.cxx

@@ -2,22 +2,22 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmIncludeRegularExpressionCommand.h"
 
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 
-class cmExecutionStatus;
-
-// cmIncludeRegularExpressionCommand
-bool cmIncludeRegularExpressionCommand::InitialPass(
-  std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmIncludeRegularExpressionCommand(std::vector<std::string> const& args,
+                                       cmExecutionStatus& status)
 {
-  if ((args.empty()) || (args.size() > 2)) {
-    this->SetError("called with incorrect number of arguments");
+  if (args.empty() || args.size() > 2) {
+    status.SetError("called with incorrect number of arguments");
     return false;
   }
-  this->Makefile->SetIncludeRegularExpression(args[0].c_str());
+
+  cmMakefile& mf = status.GetMakefile();
+  mf.SetIncludeRegularExpression(args[0].c_str());
 
   if (args.size() > 1) {
-    this->Makefile->SetComplainRegularExpression(args[1]);
+    mf.SetComplainRegularExpression(args[1]);
   }
 
   return true;

+ 2 - 28
Source/cmIncludeRegularExpressionCommand.h

@@ -8,35 +8,9 @@
 #include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
 class cmExecutionStatus;
 
-/** \class cmIncludeRegularExpressionCommand
- * \brief Set the regular expression for following #includes.
- *
- * cmIncludeRegularExpressionCommand is used to specify the regular expression
- * that determines whether to follow a #include file in dependency checking.
- */
-class cmIncludeRegularExpressionCommand : public cmCommand
-{
-public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmIncludeRegularExpressionCommand>();
-  }
-
-  /**
-   * 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 cmIncludeRegularExpressionCommand(std::vector<std::string> const& args,
+                                       cmExecutionStatus& status);
 
 #endif