mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-13 12:59:55 -05:00
cmGeneratorTarget: Simplify storage of link implementation
With CMP0022 removed, the link implementation is now computed only for the target itself, and never for a dependent head target.
This commit is contained in:
@@ -5012,7 +5012,7 @@ bool cmGeneratorTarget::DiscoverSyntheticTargets(cmSyntheticTargetCache& cache,
|
|||||||
std::vector<std::string> allConfigs =
|
std::vector<std::string> allConfigs =
|
||||||
this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
|
this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
|
||||||
cmOptionalLinkImplementation impl;
|
cmOptionalLinkImplementation impl;
|
||||||
this->ComputeLinkImplementationLibraries(config, impl, this, UseTo::Link);
|
this->ComputeLinkImplementationLibraries(config, impl, UseTo::Link);
|
||||||
|
|
||||||
cmCxxModuleUsageEffects usage(this);
|
cmCxxModuleUsageEffects usage(this);
|
||||||
|
|
||||||
|
|||||||
@@ -449,7 +449,6 @@ public:
|
|||||||
|
|
||||||
void ComputeLinkImplementationLibraries(const std::string& config,
|
void ComputeLinkImplementationLibraries(const std::string& config,
|
||||||
cmOptionalLinkImplementation& impl,
|
cmOptionalLinkImplementation& impl,
|
||||||
const cmGeneratorTarget* head,
|
|
||||||
UseTo usage) const;
|
UseTo usage) const;
|
||||||
|
|
||||||
struct TargetOrString
|
struct TargetOrString
|
||||||
@@ -1360,22 +1359,10 @@ private:
|
|||||||
void GetSourceFilesWithoutObjectLibraries(std::vector<cmSourceFile*>& files,
|
void GetSourceFilesWithoutObjectLibraries(std::vector<cmSourceFile*>& files,
|
||||||
const std::string& config) const;
|
const std::string& config) const;
|
||||||
|
|
||||||
struct HeadToLinkImplementationMap
|
using LinkImplMapType = std::map<std::string, cmOptionalLinkImplementation>;
|
||||||
: public std::map<cmGeneratorTarget const*, cmOptionalLinkImplementation>
|
|
||||||
{
|
|
||||||
};
|
|
||||||
using LinkImplMapType = std::map<std::string, HeadToLinkImplementationMap>;
|
|
||||||
mutable LinkImplMapType LinkImplMap;
|
mutable LinkImplMapType LinkImplMap;
|
||||||
mutable LinkImplMapType LinkImplUsageRequirementsOnlyMap;
|
mutable LinkImplMapType LinkImplUsageRequirementsOnlyMap;
|
||||||
|
|
||||||
HeadToLinkImplementationMap& GetHeadToLinkImplementationMap(
|
|
||||||
std::string const& config) const;
|
|
||||||
HeadToLinkImplementationMap& GetHeadToLinkImplementationUsageRequirementsMap(
|
|
||||||
std::string const& config) const;
|
|
||||||
|
|
||||||
cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(
|
|
||||||
const std::string& config, const cmGeneratorTarget* head,
|
|
||||||
UseTo usage) const;
|
|
||||||
bool ComputeOutputDir(const std::string& config,
|
bool ComputeOutputDir(const std::string& config,
|
||||||
cmStateEnums::ArtifactType artifact,
|
cmStateEnums::ArtifactType artifact,
|
||||||
std::string& out) const;
|
std::string& out) const;
|
||||||
|
|||||||
@@ -382,16 +382,8 @@ void cmGeneratorTarget::CheckLinkLibraries() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check link the implementation for each generated configuration.
|
// Check link the implementation for each generated configuration.
|
||||||
for (auto const& hmp : this->LinkImplMap) {
|
for (auto const& impl : this->LinkImplMap) {
|
||||||
HeadToLinkImplementationMap const& hm = hmp.second;
|
for (cmLinkImplItem const& item : impl.second.Libraries) {
|
||||||
// There could be several entries used when computing the pre-CMP0022
|
|
||||||
// default link interface. Check only the entry for our own link impl.
|
|
||||||
auto const hmi = hm.find(this);
|
|
||||||
if (hmi == hm.end() || !hmi->second.LibrariesDone ||
|
|
||||||
!hmi->second.CheckLinkLibraries) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (cmLinkImplItem const& item : hmi->second.Libraries) {
|
|
||||||
if (!this->VerifyLinkItemColons(LinkItemRole::Implementation, item)) {
|
if (!this->VerifyLinkItemColons(LinkItemRole::Implementation, item)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -996,18 +988,18 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeadToLinkImplementationMap& hm =
|
cmOptionalLinkImplementation& impl =
|
||||||
(usage == UseTo::Compile
|
(usage == UseTo::Compile
|
||||||
? this->GetHeadToLinkImplementationUsageRequirementsMap(config)
|
? this
|
||||||
: this->GetHeadToLinkImplementationMap(config));
|
->LinkImplUsageRequirementsOnlyMap[cmSystemTools::UpperCase(config)]
|
||||||
cmOptionalLinkImplementation& impl = hm[this];
|
: this->LinkImplMap[cmSystemTools::UpperCase(config)]);
|
||||||
if (secondPass) {
|
if (secondPass) {
|
||||||
impl = cmOptionalLinkImplementation();
|
impl = cmOptionalLinkImplementation();
|
||||||
}
|
}
|
||||||
MaybeEnableCheckLinkLibraries(impl);
|
MaybeEnableCheckLinkLibraries(impl);
|
||||||
if (!impl.LibrariesDone) {
|
if (!impl.LibrariesDone) {
|
||||||
impl.LibrariesDone = true;
|
impl.LibrariesDone = true;
|
||||||
this->ComputeLinkImplementationLibraries(config, impl, this, usage);
|
this->ComputeLinkImplementationLibraries(config, impl, usage);
|
||||||
}
|
}
|
||||||
if (!impl.LanguagesDone) {
|
if (!impl.LanguagesDone) {
|
||||||
impl.LanguagesDone = true;
|
impl.LanguagesDone = true;
|
||||||
@@ -1017,31 +1009,9 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
|
|||||||
return &impl;
|
return &impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGeneratorTarget::HeadToLinkImplementationMap&
|
|
||||||
cmGeneratorTarget::GetHeadToLinkImplementationMap(
|
|
||||||
std::string const& config) const
|
|
||||||
{
|
|
||||||
return this->LinkImplMap[cmSystemTools::UpperCase(config)];
|
|
||||||
}
|
|
||||||
|
|
||||||
cmGeneratorTarget::HeadToLinkImplementationMap&
|
|
||||||
cmGeneratorTarget::GetHeadToLinkImplementationUsageRequirementsMap(
|
|
||||||
std::string const& config) const
|
|
||||||
{
|
|
||||||
return this
|
|
||||||
->LinkImplUsageRequirementsOnlyMap[cmSystemTools::UpperCase(config)];
|
|
||||||
}
|
|
||||||
|
|
||||||
cmLinkImplementationLibraries const*
|
cmLinkImplementationLibraries const*
|
||||||
cmGeneratorTarget::GetLinkImplementationLibraries(const std::string& config,
|
cmGeneratorTarget::GetLinkImplementationLibraries(const std::string& config,
|
||||||
UseTo usage) const
|
UseTo usage) const
|
||||||
{
|
|
||||||
return this->GetLinkImplementationLibrariesInternal(config, this, usage);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmLinkImplementationLibraries const*
|
|
||||||
cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
|
|
||||||
const std::string& config, cmGeneratorTarget const* head, UseTo usage) const
|
|
||||||
{
|
{
|
||||||
// There is no link implementation for targets that cannot compile sources.
|
// There is no link implementation for targets that cannot compile sources.
|
||||||
if (!this->CanCompileSources()) {
|
if (!this->CanCompileSources()) {
|
||||||
@@ -1049,22 +1019,15 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Populate the link implementation libraries for this configuration.
|
// Populate the link implementation libraries for this configuration.
|
||||||
HeadToLinkImplementationMap& hm =
|
cmOptionalLinkImplementation& impl =
|
||||||
(usage == UseTo::Compile
|
(usage == UseTo::Compile
|
||||||
? this->GetHeadToLinkImplementationUsageRequirementsMap(config)
|
? this
|
||||||
: this->GetHeadToLinkImplementationMap(config));
|
->LinkImplUsageRequirementsOnlyMap[cmSystemTools::UpperCase(config)]
|
||||||
|
: this->LinkImplMap[cmSystemTools::UpperCase(config)]);
|
||||||
// If the link implementation does not depend on the head target
|
|
||||||
// then reuse the one from the head we computed first.
|
|
||||||
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
|
|
||||||
head = hm.begin()->first;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmOptionalLinkImplementation& impl = hm[head];
|
|
||||||
MaybeEnableCheckLinkLibraries(impl);
|
MaybeEnableCheckLinkLibraries(impl);
|
||||||
if (!impl.LibrariesDone) {
|
if (!impl.LibrariesDone) {
|
||||||
impl.LibrariesDone = true;
|
impl.LibrariesDone = true;
|
||||||
this->ComputeLinkImplementationLibraries(config, impl, head, usage);
|
this->ComputeLinkImplementationLibraries(config, impl, usage);
|
||||||
}
|
}
|
||||||
return &impl;
|
return &impl;
|
||||||
}
|
}
|
||||||
@@ -1177,7 +1140,7 @@ void ComputeLinkImplTransitive(cmGeneratorTarget const* self,
|
|||||||
|
|
||||||
void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
||||||
const std::string& config, cmOptionalLinkImplementation& impl,
|
const std::string& config, cmOptionalLinkImplementation& impl,
|
||||||
cmGeneratorTarget const* head, UseTo usage) const
|
UseTo usage) const
|
||||||
{
|
{
|
||||||
cmLocalGenerator const* lg = this->LocalGenerator;
|
cmLocalGenerator const* lg = this->LocalGenerator;
|
||||||
cmMakefile const* mf = lg->GetMakefile();
|
cmMakefile const* mf = lg->GetMakefile();
|
||||||
@@ -1207,7 +1170,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
|||||||
ge.Parse(entry.Value);
|
ge.Parse(entry.Value);
|
||||||
cge->SetEvaluateForBuildsystem(true);
|
cge->SetEvaluateForBuildsystem(true);
|
||||||
std::string const& evaluated =
|
std::string const& evaluated =
|
||||||
cge->Evaluate(this->LocalGenerator, config, head, &dagChecker, nullptr,
|
cge->Evaluate(this->LocalGenerator, config, this, &dagChecker, nullptr,
|
||||||
this->LinkerLanguage);
|
this->LinkerLanguage);
|
||||||
bool const checkCMP0027 = evaluated != entry.Value;
|
bool const checkCMP0027 = evaluated != entry.Value;
|
||||||
cmList llibs(evaluated);
|
cmList llibs(evaluated);
|
||||||
@@ -1309,9 +1272,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the list of direct link dependencies from usage requirements.
|
// Update the list of direct link dependencies from usage requirements.
|
||||||
if (head == this) {
|
ComputeLinkImplTransitive(this, config, usage, impl);
|
||||||
ComputeLinkImplTransitive(this, config, usage, impl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the list of configurations considered to be DEBUG.
|
// Get the list of configurations considered to be DEBUG.
|
||||||
std::vector<std::string> debugConfigs =
|
std::vector<std::string> debugConfigs =
|
||||||
|
|||||||
Reference in New Issue
Block a user