cmGeneratorTarget: Move GetLinkImplementationClosure

This commit is contained in:
Stephen Kelly 2015-08-04 19:19:44 +02:00
parent 97f10e488a
commit 7da4c9d4ed
4 changed files with 63 additions and 60 deletions

View File

@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
} }
std::vector<cmTarget const*> const& deps = std::vector<cmTarget const*> const& deps =
this->Target->GetLinkImplementationClosure(config); this->GetLinkImplementationClosure(config);
for(std::vector<cmTarget const*>::const_iterator for(std::vector<cmTarget const*>::const_iterator
li = deps.begin(), le = deps.end(); li != le; ++li) li = deps.begin(), le = deps.end(); li != le; ++li)
{ {
@ -774,6 +774,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string> &result,
result); result);
} }
//----------------------------------------------------------------------------
void processILibs(const std::string& config,
cmTarget const* headTarget,
cmLinkItem const& item,
std::vector<cmTarget const*>& tgts,
std::set<cmTarget const*>& emitted)
{
if (item.Target && emitted.insert(item.Target).second)
{
tgts.push_back(item.Target);
if(cmTarget::LinkInterfaceLibraries const* iface =
item.Target->GetLinkInterfaceLibraries(config, headTarget, true))
{
for(std::vector<cmLinkItem>::const_iterator
it = iface->Libraries.begin();
it != iface->Libraries.end(); ++it)
{
processILibs(config, headTarget, *it, tgts, emitted);
}
}
}
}
//----------------------------------------------------------------------------
const std::vector<const cmTarget*>&
cmGeneratorTarget::GetLinkImplementationClosure(
const std::string& config) const
{
LinkImplClosure& tgts =
this->LinkImplClosureMap[config];
if(!tgts.Done)
{
tgts.Done = true;
std::set<cmTarget const*> emitted;
cmTarget::LinkImplementationLibraries const* impl
= this->Target->GetLinkImplementationLibraries(config);
for(std::vector<cmLinkImplItem>::const_iterator
it = impl->Libraries.begin();
it != impl->Libraries.end(); ++it)
{
processILibs(config, this->Target, *it, tgts , emitted);
}
}
return tgts;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class cmTargetTraceDependencies class cmTargetTraceDependencies
{ {
@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsBool.insert("POSITION_INDEPENDENT_CODE");
compat.PropsString.insert("AUTOUIC_OPTIONS"); compat.PropsString.insert("AUTOUIC_OPTIONS");
std::vector<cmTarget const*> const& deps = std::vector<cmTarget const*> const& deps =
this->Target->GetLinkImplementationClosure(config); this->GetLinkImplementationClosure(config);
for(std::vector<cmTarget const*>::const_iterator li = deps.begin(); for(std::vector<cmTarget const*>::const_iterator li = deps.begin();
li != deps.end(); ++li) li != deps.end(); ++li)
{ {
@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
|| (!impliedByUse && !explicitlySet)); || (!impliedByUse && !explicitlySet));
std::vector<cmTarget const*> const& deps = std::vector<cmTarget const*> const& deps =
tgt->Target->GetLinkImplementationClosure(config); tgt->GetLinkImplementationClosure(config);
if(deps.empty()) if(deps.empty())
{ {

View File

@ -245,6 +245,18 @@ private:
cmGeneratorTarget(cmGeneratorTarget const&); cmGeneratorTarget(cmGeneratorTarget const&);
void operator=(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&);
struct LinkImplClosure: public std::vector<cmTarget const*>
{
LinkImplClosure(): Done(false) {}
bool Done;
};
mutable std::map<std::string, LinkImplClosure> LinkImplClosureMap;
public:
std::vector<cmTarget const*> const&
GetLinkImplementationClosure(const std::string& config) const;
}; };
struct cmStrictTargetComparison { struct cmStrictTargetComparison {

View File

@ -163,13 +163,6 @@ public:
typedef std::map<std::string, cmTarget::LinkClosure> LinkClosureMapType; typedef std::map<std::string, cmTarget::LinkClosure> LinkClosureMapType;
LinkClosureMapType LinkClosureMap; LinkClosureMapType LinkClosureMap;
struct LinkImplClosure: public std::vector<cmTarget const*>
{
LinkImplClosure(): Done(false) {}
bool Done;
};
std::map<std::string, LinkImplClosure> LinkImplClosureMap;
typedef std::map<std::string, std::vector<cmSourceFile*> > typedef std::map<std::string, std::vector<cmSourceFile*> >
SourceFilesMapType; SourceFilesMapType;
SourceFilesMapType SourceFilesMap; SourceFilesMapType SourceFilesMap;
@ -5174,53 +5167,6 @@ cmTarget::GetImportLinkInterface(const std::string& config,
return &iface; return &iface;
} }
//----------------------------------------------------------------------------
void processILibs(const std::string& config,
cmTarget const* headTarget,
cmLinkItem const& item,
std::vector<cmTarget const*>& tgts,
std::set<cmTarget const*>& emitted)
{
if (item.Target && emitted.insert(item.Target).second)
{
tgts.push_back(item.Target);
if(cmTarget::LinkInterfaceLibraries const* iface =
item.Target->GetLinkInterfaceLibraries(config, headTarget, true))
{
for(std::vector<cmLinkItem>::const_iterator
it = iface->Libraries.begin();
it != iface->Libraries.end(); ++it)
{
processILibs(config, headTarget, *it, tgts, emitted);
}
}
}
}
//----------------------------------------------------------------------------
std::vector<cmTarget const*> const&
cmTarget::GetLinkImplementationClosure(const std::string& config) const
{
cmTargetInternals::LinkImplClosure& tgts =
this->Internal->LinkImplClosureMap[config];
if(!tgts.Done)
{
tgts.Done = true;
std::set<cmTarget const*> emitted;
cmTarget::LinkImplementationLibraries const* impl
= this->GetLinkImplementationLibraries(config);
for(std::vector<cmLinkImplItem>::const_iterator
it = impl->Libraries.begin();
it != impl->Libraries.end(); ++it)
{
processILibs(config, this, *it, tgts , emitted);
}
}
return tgts;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmTargetInternals::ComputeLinkInterfaceLibraries( cmTargetInternals::ComputeLinkInterfaceLibraries(

View File

@ -293,9 +293,6 @@ public:
cmTarget const* headTarget, cmTarget const* headTarget,
bool usage_requirements_only) const; bool usage_requirements_only) const;
std::vector<cmTarget const*> const&
GetLinkImplementationClosure(const std::string& config) const;
/** The link implementation specifies the direct library /** The link implementation specifies the direct library
dependencies needed by the object files of the target. */ dependencies needed by the object files of the target. */
struct LinkImplementationLibraries struct LinkImplementationLibraries