瀏覽代碼

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)
 {
   // Set our makefile.

+ 3 - 0
Source/cmTarget.h

@@ -86,6 +86,9 @@ public:
   ///! Set/Get the name of the target
   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
   void SetMakefile(cmMakefile* mf);
   cmMakefile* GetMakefile() const { return this->Makefile; }