diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-01-30 15:36:44 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-02-14 17:33:58 (GMT) |
commit | c97de1047f2fd08a74c42982012e8bb96a5e2f89 (patch) | |
tree | e72fb32152d5e30701a94d597cb9c089f0ed57f8 | |
parent | 1d0426f6426ef88342f3a57fb555a2b2d8891712 (diff) | |
download | CMake-c97de1047f2fd08a74c42982012e8bb96a5e2f89.zip CMake-c97de1047f2fd08a74c42982012e8bb96a5e2f89.tar.gz CMake-c97de1047f2fd08a74c42982012e8bb96a5e2f89.tar.bz2 |
cmMakefile: add support for a "synthesized" target
It is a normal target, but will end up copying its internals from
another target. Keep track of this state so that such copying can only
occur when intended.
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 5 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 1 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 15 | ||||
-rw-r--r-- | Source/cmMakefile.h | 5 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 17 | ||||
-rw-r--r-- | Source/cmTarget.h | 2 |
6 files changed, 41 insertions, 4 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2202507..b99892b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1242,6 +1242,11 @@ bool cmGeneratorTarget::IsNormal() const return this->Target->IsNormal(); } +bool cmGeneratorTarget::IsSynthetic() const +{ + return this->Target->IsSynthetic(); +} + bool cmGeneratorTarget::IsImported() const { return this->Target->IsImported(); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 210022e..e46c719 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -51,6 +51,7 @@ public: bool IsInBuildSystem() const; bool IsNormal() const; + bool IsSynthetic() const; bool IsImported() const; bool IsImportedGloballyVisible() const; bool CanCompileSources() const; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 457204a..d963a5a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2115,12 +2115,21 @@ cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type, return &this->CreateNewTarget(name, type).first; } +cmTarget* cmMakefile::AddSynthesizedTarget(cmStateEnums::TargetType type, + const std::string& name) +{ + return &this + ->CreateNewTarget(name, type, cmTarget::PerConfig::Yes, + cmTarget::Visibility::Generated) + .first; +} + std::pair<cmTarget&, bool> cmMakefile::CreateNewTarget( const std::string& name, cmStateEnums::TargetType type, - cmTarget::PerConfig perConfig) + cmTarget::PerConfig perConfig, cmTarget::Visibility vis) { - auto ib = this->Targets.emplace( - name, cmTarget(name, type, cmTarget::Visibility::Normal, this, perConfig)); + auto ib = + this->Targets.emplace(name, cmTarget(name, type, vis, this, perConfig)); auto it = ib.first; if (!ib.second) { return std::make_pair(std::ref(it->second), false); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 3866aca..7b19c97 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -241,10 +241,13 @@ public: std::pair<cmTarget&, bool> CreateNewTarget( const std::string& name, cmStateEnums::TargetType type, - cmTarget::PerConfig perConfig = cmTarget::PerConfig::Yes); + cmTarget::PerConfig perConfig = cmTarget::PerConfig::Yes, + cmTarget::Visibility vis = cmTarget::Visibility::Normal); cmTarget* AddNewTarget(cmStateEnums::TargetType type, const std::string& name); + cmTarget* AddSynthesizedTarget(cmStateEnums::TargetType type, + const std::string& name); /** Create a target instance for the utility. */ cmTarget* AddNewUtilityTarget(const std::string& utilityName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 48f92b5..91d5de6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2559,6 +2559,7 @@ bool cmTarget::IsNormal() const switch (this->impl->TargetVisibility) { case Visibility::Normal: return true; + case Visibility::Generated: case Visibility::Imported: case Visibility::ImportedGlobally: return false; @@ -2567,6 +2568,20 @@ bool cmTarget::IsNormal() const return false; } +bool cmTarget::IsSynthetic() const +{ + switch (this->impl->TargetVisibility) { + case Visibility::Generated: + return true; + case Visibility::Normal: + case Visibility::Imported: + case Visibility::ImportedGlobally: + return false; + } + assert(false && "unknown visibility (IsSynthetic)"); + return false; +} + bool cmTargetInternals::IsImported() const { switch (this->TargetVisibility) { @@ -2574,6 +2589,7 @@ bool cmTargetInternals::IsImported() const case cmTarget::Visibility::ImportedGlobally: return true; case cmTarget::Visibility::Normal: + case cmTarget::Visibility::Generated: return false; } assert(false && "unknown visibility (IsImported)"); @@ -2591,6 +2607,7 @@ bool cmTarget::IsImportedGloballyVisible() const case Visibility::ImportedGlobally: return true; case Visibility::Normal: + case Visibility::Generated: case Visibility::Imported: return false; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b96bdf2..95539fa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -49,6 +49,7 @@ public: enum class Visibility { Normal, + Generated, Imported, ImportedGlobally, }; @@ -206,6 +207,7 @@ public: bool IsAIX() const; bool IsNormal() const; + bool IsSynthetic() const; bool IsImported() const; bool IsImportedGloballyVisible() const; bool IsPerConfig() const; |