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.
This commit is contained in:
parent
1d0426f642
commit
c97de1047f
@ -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();
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
|
||||
bool IsInBuildSystem() const;
|
||||
bool IsNormal() const;
|
||||
bool IsSynthetic() const;
|
||||
bool IsImported() const;
|
||||
bool IsImportedGloballyVisible() const;
|
||||
bool CanCompileSources() const;
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user