Browse Source

cmCustomCommand: Move custom commands

Daniel Eiband 6 years ago
parent
commit
91abf9f3c4

+ 1 - 1
Source/cmGlobalGenerator.cxx

@@ -2582,7 +2582,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
   cmCustomCommand cc(nullptr, no_outputs, no_byproducts, no_depends,
                      gti.CommandLines, nullptr, gti.WorkingDir.c_str());
   cc.SetUsesTerminal(gti.UsesTerminal);
-  target.AddPostBuildCommand(cc);
+  target.AddPostBuildCommand(std::move(cc));
   if (!gti.Message.empty()) {
     target.SetProperty("EchoString", gti.Message.c_str());
   }

+ 3 - 3
Source/cmMakefile.cxx

@@ -938,13 +938,13 @@ void cmMakefile::CommitCustomCommandToTarget(
   cc.SetJobPool(job_pool);
   switch (type) {
     case cmCustomCommandType::PRE_BUILD:
-      target->AddPreBuildCommand(cc);
+      target->AddPreBuildCommand(std::move(cc));
       break;
     case cmCustomCommandType::PRE_LINK:
-      target->AddPreLinkCommand(cc);
+      target->AddPreLinkCommand(std::move(cc));
       break;
     case cmCustomCommandType::POST_BUILD:
-      target->AddPostBuildCommand(cc);
+      target->AddPostBuildCommand(std::move(cc));
       break;
   }
   this->UpdateOutputToSourceMap(byproducts, target);

+ 1 - 1
Source/cmQtAutoGenInitializer.cxx

@@ -1086,7 +1086,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
                        this->Dir.Work.c_str());
     cc.SetEscapeOldStyle(false);
     cc.SetEscapeAllowMakeVars(true);
-    this->GenTarget->Target->AddPreBuildCommand(cc);
+    this->GenTarget->Target->AddPreBuildCommand(std::move(cc));
   } else {
 
     // Add link library target dependencies to the autogen target

+ 15 - 0
Source/cmTarget.cxx

@@ -604,6 +604,11 @@ void cmTarget::AddPreBuildCommand(cmCustomCommand const& cmd)
   impl->PreBuildCommands.push_back(cmd);
 }
 
+void cmTarget::AddPreBuildCommand(cmCustomCommand&& cmd)
+{
+  impl->PreBuildCommands.push_back(std::move(cmd));
+}
+
 std::vector<cmCustomCommand> const& cmTarget::GetPreLinkCommands() const
 {
   return impl->PreLinkCommands;
@@ -614,6 +619,11 @@ void cmTarget::AddPreLinkCommand(cmCustomCommand const& cmd)
   impl->PreLinkCommands.push_back(cmd);
 }
 
+void cmTarget::AddPreLinkCommand(cmCustomCommand&& cmd)
+{
+  impl->PreLinkCommands.push_back(std::move(cmd));
+}
+
 std::vector<cmCustomCommand> const& cmTarget::GetPostBuildCommands() const
 {
   return impl->PostBuildCommands;
@@ -624,6 +634,11 @@ void cmTarget::AddPostBuildCommand(cmCustomCommand const& cmd)
   impl->PostBuildCommands.push_back(cmd);
 }
 
+void cmTarget::AddPostBuildCommand(cmCustomCommand&& cmd)
+{
+  impl->PostBuildCommands.push_back(std::move(cmd));
+}
+
 void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
 {
   if (!srcs.empty()) {

+ 3 - 0
Source/cmTarget.h

@@ -84,14 +84,17 @@ public:
   //! Get the list of the PRE_BUILD custom commands for this target
   std::vector<cmCustomCommand> const& GetPreBuildCommands() const;
   void AddPreBuildCommand(cmCustomCommand const& cmd);
+  void AddPreBuildCommand(cmCustomCommand&& cmd);
 
   //! Get the list of the PRE_LINK custom commands for this target
   std::vector<cmCustomCommand> const& GetPreLinkCommands() const;
   void AddPreLinkCommand(cmCustomCommand const& cmd);
+  void AddPreLinkCommand(cmCustomCommand&& cmd);
 
   //! Get the list of the POST_BUILD custom commands for this target
   std::vector<cmCustomCommand> const& GetPostBuildCommands() const;
   void AddPostBuildCommand(cmCustomCommand const& cmd);
+  void AddPostBuildCommand(cmCustomCommand&& cmd);
 
   //! Add sources to the target.
   void AddSources(std::vector<std::string> const& srcs);