瀏覽代碼

cmRemoveDefinitionsCommand: Port away from cmCommand

Ref: #19499
Regina Pfeifer 6 年之前
父節點
當前提交
706400d417
共有 3 個文件被更改,包括 8 次插入42 次删除
  1. 1 2
      Source/cmCommands.cxx
  2. 5 11
      Source/cmRemoveDefinitionsCommand.cxx
  3. 2 29
      Source/cmRemoveDefinitionsCommand.h

+ 1 - 2
Source/cmCommands.cxx

@@ -291,8 +291,7 @@ void GetProjectCommands(cmState* state)
                            cm::make_unique<cmLoadCacheCommand>());
   state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand);
   state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand);
-  state->AddBuiltinCommand("remove_definitions",
-                           cm::make_unique<cmRemoveDefinitionsCommand>());
+  state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand);
   state->AddBuiltinCommand("source_group",
                            cm::make_unique<cmSourceGroupCommand>());
 

+ 5 - 11
Source/cmRemoveDefinitionsCommand.cxx

@@ -2,21 +2,15 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmRemoveDefinitionsCommand.h"
 
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 
-class cmExecutionStatus;
-
-// cmRemoveDefinitionsCommand
-bool cmRemoveDefinitionsCommand::InitialPass(
-  std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmRemoveDefinitionsCommand(std::vector<std::string> const& args,
+                                cmExecutionStatus& status)
 {
-  // it is OK to have no arguments
-  if (args.empty()) {
-    return true;
-  }
-
+  cmMakefile& mf = status.GetMakefile();
   for (std::string const& i : args) {
-    this->Makefile->RemoveDefineFlag(i);
+    mf.RemoveDefineFlag(i);
   }
   return true;
 }

+ 2 - 29
Source/cmRemoveDefinitionsCommand.h

@@ -8,36 +8,9 @@
 #include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
 class cmExecutionStatus;
 
-/** \class cmRemoveDefinitionsCommand
- * \brief Specify a list of compiler defines
- *
- * cmRemoveDefinitionsCommand specifies a list of compiler defines.
- * These defines will
- * be removed from the compile command.
- */
-class cmRemoveDefinitionsCommand : public cmCommand
-{
-public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmRemoveDefinitionsCommand>();
-  }
-
-  /**
-   * 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 cmRemoveDefinitionsCommand(std::vector<std::string> const& args,
+                                cmExecutionStatus& status);
 
 #endif