From d97513d842c51e4fb996d42e1f04a9c291e3d5bf Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Sep 2016 13:38:00 -0400 Subject: 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. --- Source/cmTarget.cxx | 9 +++++++++ Source/cmTarget.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d5274cd..dc3944c 100644 --- a/Source/cmTarget.cxx +++ b/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. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index fc30166..b0bfc72 100644 --- a/Source/cmTarget.h +++ b/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; } -- cgit v0.12