summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-01-30 10:36:44 -0500
committerBen Boeckel <ben.boeckel@kitware.com>2023-02-14 12:33:58 -0500
commitc97de1047f2fd08a74c42982012e8bb96a5e2f89 (patch)
treee72fb32152d5e30701a94d597cb9c089f0ed57f8 /Source
parent1d0426f6426ef88342f3a57fb555a2b2d8891712 (diff)
downloadcmake-c97de1047f2fd08a74c42982012e8bb96a5e2f89.tar.gz
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx5
-rw-r--r--Source/cmGeneratorTarget.h1
-rw-r--r--Source/cmMakefile.cxx15
-rw-r--r--Source/cmMakefile.h5
-rw-r--r--Source/cmTarget.cxx17
-rw-r--r--Source/cmTarget.h2
6 files changed, 41 insertions, 4 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 22025071e1..b99892b246 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 210022edfc..e46c71967b 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 457204a53b..d963a5aa0b 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 3866aca7f2..7b19c9760f 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 48f92b5537..91d5de6c8c 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 b96bdf2672..95539fa674 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;