Browse Source

cmCommand refactor: cmExportLibraryDependenciesCommand

Gabor Bencze 6 years ago
parent
commit
9d6fc3f5ed

+ 2 - 2
Source/cmCommands.cxx

@@ -309,8 +309,8 @@ void GetProjectCommands(cmState* state)
                            cm::make_unique<cmSourceGroupCommand>());
 
   state->AddDisallowedCommand(
-    "export_library_dependencies",
-    cm::make_unique<cmExportLibraryDependenciesCommand>(), cmPolicies::CMP0033,
+    "export_library_dependencies", cmExportLibraryDependenciesCommand,
+    cmPolicies::CMP0033,
     "The export_library_dependencies command should not be called; "
     "see CMP0033.");
   state->AddDisallowedCommand(

+ 8 - 8
Source/cmExportLibraryDependenciesCommand.cxx

@@ -8,6 +8,7 @@
 
 #include "cm_memory.hxx"
 
+#include "cmExecutionStatus.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
@@ -18,8 +19,6 @@
 #include "cmTargetLinkLibraryType.h"
 #include "cmake.h"
 
-class cmExecutionStatus;
-
 static void FinalAction(cmMakefile& makefile, std::string const& filename,
                         bool append)
 {
@@ -140,19 +139,20 @@ static void FinalAction(cmMakefile& makefile, std::string const& filename,
   fout << "endif()\n";
 }
 
-bool cmExportLibraryDependenciesCommand::InitialPass(
-  std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
+                                        cmExecutionStatus& status)
 {
   if (args.empty()) {
-    this->SetError("called with incorrect number of arguments");
+    status.SetError("called with incorrect number of arguments");
     return false;
   }
 
   std::string const& filename = args[0];
   bool const append = args.size() > 1 && args[1] == "APPEND";
-  this->Makefile->AddFinalAction([filename, append](cmMakefile& makefile) {
-    FinalAction(makefile, filename, append);
-  });
+  status.GetMakefile().AddFinalAction(
+    [filename, append](cmMakefile& makefile) {
+      FinalAction(makefile, filename, append);
+    });
 
   return true;
 }

+ 2 - 14
Source/cmExportLibraryDependenciesCommand.h

@@ -8,21 +8,9 @@
 #include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
 class cmExecutionStatus;
 
-class cmExportLibraryDependenciesCommand : public cmCommand
-{
-public:
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmExportLibraryDependenciesCommand>();
-  }
-  bool InitialPass(std::vector<std::string> const& args,
-                   cmExecutionStatus& status) override;
-};
+bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
+                                        cmExecutionStatus& status);
 
 #endif