cmLinkItem: Add cmOptionalLinkImplementation type.
Move the associated Compute* methods to the cmTarget class.
This commit is contained in:
parent
3846ebcf2b
commit
771e79a2bf
|
@ -107,4 +107,15 @@ struct cmLinkImplementation: public cmLinkImplementationLibraries
|
||||||
std::vector<std::string> Languages;
|
std::vector<std::string> Languages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Cache link implementation computation from each configuration.
|
||||||
|
struct cmOptionalLinkImplementation: public cmLinkImplementation
|
||||||
|
{
|
||||||
|
cmOptionalLinkImplementation():
|
||||||
|
LibrariesDone(false), LanguagesDone(false),
|
||||||
|
HadHeadSensitiveCondition(false) {}
|
||||||
|
bool LibrariesDone;
|
||||||
|
bool LanguagesDone;
|
||||||
|
bool HadHeadSensitiveCondition;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -95,27 +95,8 @@ public:
|
||||||
typedef std::map<std::string, cmTarget::ImportInfo> ImportInfoMapType;
|
typedef std::map<std::string, cmTarget::ImportInfo> ImportInfoMapType;
|
||||||
ImportInfoMapType ImportInfoMap;
|
ImportInfoMapType ImportInfoMap;
|
||||||
|
|
||||||
// Cache link implementation computation from each configuration.
|
|
||||||
struct OptionalLinkImplementation: public cmLinkImplementation
|
|
||||||
{
|
|
||||||
OptionalLinkImplementation():
|
|
||||||
LibrariesDone(false), LanguagesDone(false),
|
|
||||||
HadHeadSensitiveCondition(false) {}
|
|
||||||
bool LibrariesDone;
|
|
||||||
bool LanguagesDone;
|
|
||||||
bool HadHeadSensitiveCondition;
|
|
||||||
};
|
|
||||||
void ComputeLinkImplementationLibraries(cmTarget const* thisTarget,
|
|
||||||
const std::string& config,
|
|
||||||
OptionalLinkImplementation& impl,
|
|
||||||
cmTarget const* head) const;
|
|
||||||
void ComputeLinkImplementationLanguages(cmTarget const* thisTarget,
|
|
||||||
const std::string& config,
|
|
||||||
OptionalLinkImplementation& impl
|
|
||||||
) const;
|
|
||||||
|
|
||||||
struct HeadToLinkImplementationMap:
|
struct HeadToLinkImplementationMap:
|
||||||
public std::map<cmTarget const*, OptionalLinkImplementation> {};
|
public std::map<cmTarget const*, cmOptionalLinkImplementation> {};
|
||||||
typedef std::map<std::string,
|
typedef std::map<std::string,
|
||||||
HeadToLinkImplementationMap> LinkImplMapType;
|
HeadToLinkImplementationMap> LinkImplMapType;
|
||||||
LinkImplMapType LinkImplMap;
|
LinkImplMapType LinkImplMap;
|
||||||
|
@ -3595,18 +3576,17 @@ cmTarget::GetLinkImplementation(const std::string& config) const
|
||||||
|
|
||||||
// Populate the link implementation for this configuration.
|
// Populate the link implementation for this configuration.
|
||||||
std::string CONFIG = cmSystemTools::UpperCase(config);
|
std::string CONFIG = cmSystemTools::UpperCase(config);
|
||||||
cmTargetInternals::OptionalLinkImplementation&
|
cmOptionalLinkImplementation&
|
||||||
impl = this->Internal->LinkImplMap[CONFIG][this];
|
impl = this->Internal->LinkImplMap[CONFIG][this];
|
||||||
if(!impl.LibrariesDone)
|
if(!impl.LibrariesDone)
|
||||||
{
|
{
|
||||||
impl.LibrariesDone = true;
|
impl.LibrariesDone = true;
|
||||||
this->Internal
|
this->ComputeLinkImplementationLibraries(config, impl, this);
|
||||||
->ComputeLinkImplementationLibraries(this, config, impl, this);
|
|
||||||
}
|
}
|
||||||
if(!impl.LanguagesDone)
|
if(!impl.LanguagesDone)
|
||||||
{
|
{
|
||||||
impl.LanguagesDone = true;
|
impl.LanguagesDone = true;
|
||||||
this->Internal->ComputeLinkImplementationLanguages(this, config, impl);
|
this->ComputeLinkImplementationLanguages(config, impl);
|
||||||
}
|
}
|
||||||
return &impl;
|
return &impl;
|
||||||
}
|
}
|
||||||
|
@ -3641,39 +3621,36 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config,
|
||||||
return &hm.begin()->second;
|
return &hm.begin()->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTargetInternals::OptionalLinkImplementation& impl = hm[head];
|
cmOptionalLinkImplementation& impl = hm[head];
|
||||||
if(!impl.LibrariesDone)
|
if(!impl.LibrariesDone)
|
||||||
{
|
{
|
||||||
impl.LibrariesDone = true;
|
impl.LibrariesDone = true;
|
||||||
this->Internal
|
this->ComputeLinkImplementationLibraries(config, impl, head);
|
||||||
->ComputeLinkImplementationLibraries(this, config, impl, head);
|
|
||||||
}
|
}
|
||||||
return &impl;
|
return &impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void cmTarget::ComputeLinkImplementationLibraries(
|
||||||
cmTargetInternals::ComputeLinkImplementationLibraries(
|
|
||||||
cmTarget const* thisTarget,
|
|
||||||
const std::string& config,
|
const std::string& config,
|
||||||
OptionalLinkImplementation& impl,
|
cmOptionalLinkImplementation& impl,
|
||||||
cmTarget const* head) const
|
cmTarget const* head) const
|
||||||
{
|
{
|
||||||
// Collect libraries directly linked in this configuration.
|
// Collect libraries directly linked in this configuration.
|
||||||
for (std::vector<cmValueWithOrigin>::const_iterator
|
for (std::vector<cmValueWithOrigin>::const_iterator
|
||||||
le = this->LinkImplementationPropertyEntries.begin(),
|
le = this->Internal->LinkImplementationPropertyEntries.begin(),
|
||||||
end = this->LinkImplementationPropertyEntries.end();
|
end = this->Internal->LinkImplementationPropertyEntries.end();
|
||||||
le != end; ++le)
|
le != end; ++le)
|
||||||
{
|
{
|
||||||
std::vector<std::string> llibs;
|
std::vector<std::string> llibs;
|
||||||
cmGeneratorExpressionDAGChecker dagChecker(
|
cmGeneratorExpressionDAGChecker dagChecker(
|
||||||
thisTarget->GetName(),
|
this->GetName(),
|
||||||
"LINK_LIBRARIES", 0, 0);
|
"LINK_LIBRARIES", 0, 0);
|
||||||
cmGeneratorExpression ge(le->Backtrace);
|
cmGeneratorExpression ge(le->Backtrace);
|
||||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> const cge =
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> const cge =
|
||||||
ge.Parse(le->Value);
|
ge.Parse(le->Value);
|
||||||
std::string const evaluated =
|
std::string const evaluated =
|
||||||
cge->Evaluate(thisTarget->Makefile, config, false, head, &dagChecker);
|
cge->Evaluate(this->Makefile, config, false, head, &dagChecker);
|
||||||
cmSystemTools::ExpandListArgument(evaluated, llibs);
|
cmSystemTools::ExpandListArgument(evaluated, llibs);
|
||||||
if(cge->GetHadHeadSensitiveCondition())
|
if(cge->GetHadHeadSensitiveCondition())
|
||||||
{
|
{
|
||||||
|
@ -3684,15 +3661,15 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
|
||||||
li != llibs.end(); ++li)
|
li != llibs.end(); ++li)
|
||||||
{
|
{
|
||||||
// Skip entries that resolve to the target itself or are empty.
|
// Skip entries that resolve to the target itself or are empty.
|
||||||
std::string name = thisTarget->CheckCMP0004(*li);
|
std::string name = this->CheckCMP0004(*li);
|
||||||
if(name == thisTarget->GetName() || name.empty())
|
if(name == this->GetName() || name.empty())
|
||||||
{
|
{
|
||||||
if(name == thisTarget->GetName())
|
if(name == this->GetName())
|
||||||
{
|
{
|
||||||
bool noMessage = false;
|
bool noMessage = false;
|
||||||
cmake::MessageType messageType = cmake::FATAL_ERROR;
|
cmake::MessageType messageType = cmake::FATAL_ERROR;
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
switch(thisTarget->GetPolicyStatusCMP0038())
|
switch(this->GetPolicyStatusCMP0038())
|
||||||
{
|
{
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
{
|
{
|
||||||
|
@ -3711,9 +3688,9 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
|
||||||
|
|
||||||
if(!noMessage)
|
if(!noMessage)
|
||||||
{
|
{
|
||||||
e << "Target \"" << thisTarget->GetName() << "\" links to itself.";
|
e << "Target \"" << this->GetName() << "\" links to itself.";
|
||||||
thisTarget->Makefile->GetCMakeInstance()->IssueMessage(
|
this->Makefile->GetCMakeInstance()->IssueMessage(
|
||||||
messageType, e.str(), thisTarget->GetBacktrace());
|
messageType, e.str(), this->GetBacktrace());
|
||||||
if (messageType == cmake::FATAL_ERROR)
|
if (messageType == cmake::FATAL_ERROR)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -3725,7 +3702,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
|
||||||
|
|
||||||
// The entry is meant for this configuration.
|
// The entry is meant for this configuration.
|
||||||
impl.Libraries.push_back(
|
impl.Libraries.push_back(
|
||||||
cmLinkImplItem(name, thisTarget->FindTargetToLink(name),
|
cmLinkImplItem(name, this->FindTargetToLink(name),
|
||||||
le->Backtrace, evaluated != le->Value));
|
le->Backtrace, evaluated != le->Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3733,45 +3710,43 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
|
||||||
for (std::set<std::string>::const_iterator it = seenProps.begin();
|
for (std::set<std::string>::const_iterator it = seenProps.begin();
|
||||||
it != seenProps.end(); ++it)
|
it != seenProps.end(); ++it)
|
||||||
{
|
{
|
||||||
if (!thisTarget->GetProperty(*it))
|
if (!this->GetProperty(*it))
|
||||||
{
|
{
|
||||||
thisTarget->LinkImplicitNullProperties.insert(*it);
|
this->LinkImplicitNullProperties.insert(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cge->GetMaxLanguageStandard(thisTarget, thisTarget->MaxLanguageStandards);
|
cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTarget::LinkLibraryType linkType = thisTarget->ComputeLinkType(config);
|
cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config);
|
||||||
cmTarget::LinkLibraryVectorType const& oldllibs =
|
cmTarget::LinkLibraryVectorType const& oldllibs =
|
||||||
thisTarget->GetOriginalLinkLibraries();
|
this->GetOriginalLinkLibraries();
|
||||||
for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
|
for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
|
||||||
li != oldllibs.end(); ++li)
|
li != oldllibs.end(); ++li)
|
||||||
{
|
{
|
||||||
if(li->second != cmTarget::GENERAL && li->second != linkType)
|
if(li->second != cmTarget::GENERAL && li->second != linkType)
|
||||||
{
|
{
|
||||||
std::string name = thisTarget->CheckCMP0004(li->first);
|
std::string name = this->CheckCMP0004(li->first);
|
||||||
if(name == thisTarget->GetName() || name.empty())
|
if(name == this->GetName() || name.empty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Support OLD behavior for CMP0003.
|
// Support OLD behavior for CMP0003.
|
||||||
impl.WrongConfigLibraries.push_back(
|
impl.WrongConfigLibraries.push_back(
|
||||||
cmLinkItem(name, thisTarget->FindTargetToLink(name)));
|
cmLinkItem(name, this->FindTargetToLink(name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void cmTarget::ComputeLinkImplementationLanguages(
|
||||||
cmTargetInternals::ComputeLinkImplementationLanguages(
|
|
||||||
cmTarget const* thisTarget,
|
|
||||||
const std::string& config,
|
const std::string& config,
|
||||||
OptionalLinkImplementation& impl) const
|
cmOptionalLinkImplementation& impl) const
|
||||||
{
|
{
|
||||||
// This target needs runtime libraries for its source languages.
|
// This target needs runtime libraries for its source languages.
|
||||||
std::set<std::string> languages;
|
std::set<std::string> languages;
|
||||||
// Get languages used in our source files.
|
// Get languages used in our source files.
|
||||||
thisTarget->GetLanguages(languages, config);
|
this->GetLanguages(languages, config);
|
||||||
// Copy the set of langauges to the link implementation.
|
// Copy the set of langauges to the link implementation.
|
||||||
impl.Languages.insert(impl.Languages.begin(),
|
impl.Languages.insert(impl.Languages.begin(),
|
||||||
languages.begin(), languages.end());
|
languages.begin(), languages.end());
|
||||||
|
|
|
@ -237,6 +237,13 @@ public:
|
||||||
cmLinkImplementationLibraries const*
|
cmLinkImplementationLibraries const*
|
||||||
GetLinkImplementationLibraries(const std::string& config) const;
|
GetLinkImplementationLibraries(const std::string& config) const;
|
||||||
|
|
||||||
|
void ComputeLinkImplementationLibraries(const std::string& config,
|
||||||
|
cmOptionalLinkImplementation& impl,
|
||||||
|
cmTarget const* head) const;
|
||||||
|
void ComputeLinkImplementationLanguages(const std::string& config,
|
||||||
|
cmOptionalLinkImplementation& impl
|
||||||
|
) const;
|
||||||
|
|
||||||
cmTarget const* FindTargetToLink(std::string const& name) const;
|
cmTarget const* FindTargetToLink(std::string const& name) const;
|
||||||
|
|
||||||
/** Strip off leading and trailing whitespace from an item named in
|
/** Strip off leading and trailing whitespace from an item named in
|
||||||
|
|
Loading…
Reference in New Issue