Преглед на файлове

cmTarget: Add method to get a copy adapted for a directory

The "global" targets are built once for the top directory and then
copied into all directories.  Add a helper method to make the copy.
Brad King преди 9 години
родител
ревизия
d97513d842
променени са 2 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 9 0
      Source/cmTarget.cxx
  2. 3 0
      Source/cmTarget.h

+ 9 - 0
Source/cmTarget.cxx

@@ -83,6 +83,15 @@ void cmTarget::SetType(cmState::TargetType type, const std::string& name)
   }
   }
 }
 }
 
 
+cmTarget cmTarget::CopyForDirectory(cmMakefile* mf) const
+{
+  assert(this->GetType() == cmState::GLOBAL_TARGET);
+  assert(this->GetMakefile() == CM_NULLPTR);
+  cmTarget result(*this);
+  result.SetMakefile(mf);
+  return result;
+}
+
 void cmTarget::SetMakefile(cmMakefile* mf)
 void cmTarget::SetMakefile(cmMakefile* mf)
 {
 {
   // Set our makefile.
   // Set our makefile.

+ 3 - 0
Source/cmTarget.h

@@ -86,6 +86,9 @@ public:
   ///! Set/Get the name of the target
   ///! Set/Get the name of the target
   const std::string& GetName() const { return this->Name; }
   const std::string& GetName() const { return this->Name; }
 
 
+  /** Get a copy of this target adapted for the given directory.  */
+  cmTarget CopyForDirectory(cmMakefile* mf) const;
+
   ///! Set the cmMakefile that owns this target
   ///! Set the cmMakefile that owns this target
   void SetMakefile(cmMakefile* mf);
   void SetMakefile(cmMakefile* mf);
   cmMakefile* GetMakefile() const { return this->Makefile; }
   cmMakefile* GetMakefile() const { return this->Makefile; }