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.
This commit is contained in:
Brad King 2016-09-14 13:38:00 -04:00
parent ea69e03afa
commit d97513d842
2 changed files with 12 additions and 0 deletions

View File

@ -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.

View File

@ -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; }