cmGeneratorTarget: Move GetLinkInterface from cmTarget.

This commit is contained in:
Stephen Kelly 2015-08-26 19:37:45 +02:00
parent 6353816786
commit 6220241fd0
7 changed files with 69 additions and 63 deletions

View File

@ -360,9 +360,11 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe)
// Follow the item's dependencies.
if(entry.Target)
{
cmGeneratorTarget* gtgt =
this->GlobalGenerator->GetGeneratorTarget(entry.Target);
// Follow the target dependencies.
if(cmLinkInterface const* iface =
entry.Target->GetLinkInterface(this->Config, this->Target->Target))
gtgt->GetLinkInterface(this->Config, this->Target->Target))
{
const bool isIface =
entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY;
@ -459,8 +461,10 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
// Target items may have their own dependencies.
if(entry.Target)
{
cmGeneratorTarget* gtgt =
this->GlobalGenerator->GetGeneratorTarget(entry.Target);
if(cmLinkInterface const* iface =
entry.Target->GetLinkInterface(this->Config, this->Target->Target))
gtgt->GetLinkInterface(this->Config, this->Target->Target))
{
// Follow public and private dependencies transitively.
this->FollowSharedDeps(index, iface, true);
@ -930,8 +934,10 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
{
if(cmTarget const* target = this->EntryList[*ni].Target)
{
cmGeneratorTarget* gtgt =
this->GlobalGenerator->GetGeneratorTarget(target);
if(cmLinkInterface const* iface =
target->GetLinkInterface(this->Config, this->Target->Target))
gtgt->GetLinkInterface(this->Config, this->Target->Target))
{
if(iface->Multiplicity > count)
{

View File

@ -297,7 +297,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
{
cmGeneratorTarget const* depender = this->Targets[depender_index];
if(cmLinkInterface const* iface =
dependee->Target->GetLinkInterface(config,
dependee->GetLinkInterface(config,
depender->Target))
{
for(std::vector<cmLinkItem>::const_iterator

View File

@ -796,9 +796,8 @@ cmExportFileGenerator
std::vector<std::string>& missingTargets)
{
// Add the transitive link dependencies for this configuration.
cmLinkInterface const* iface = target->Target->GetLinkInterface(
config,
target->Target);
cmLinkInterface const* iface = target->GetLinkInterface(config,
target->Target);
if (!iface)
{
return;
@ -910,8 +909,7 @@ cmExportFileGenerator
// Add the transitive link dependencies for this configuration.
if(cmLinkInterface const* iface =
target->Target
->GetLinkInterface(config, target->Target))
target->GetLinkInterface(config, target->Target))
{
this->SetImportLinkProperty(suffix, target,
"IMPORTED_LINK_INTERFACE_LANGUAGES",

View File

@ -1172,9 +1172,11 @@ public:
{
return;
}
cmGeneratorTarget* gtgt =
this->Target->GetLocalGenerator()->GetGlobalGenerator()
->GetGeneratorTarget(item.Target);
cmLinkInterface const* iface =
item.Target->GetLinkInterface(this->Config, this->HeadTarget);
gtgt->GetLinkInterface(this->Config, this->HeadTarget);
if(!iface) { return; }
for(std::vector<std::string>::const_iterator
@ -3354,3 +3356,52 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport);
}
//----------------------------------------------------------------------------
cmLinkInterface const*
cmGeneratorTarget::GetLinkInterface(const std::string& config,
cmTarget const* head) const
{
// Imported targets have their own link interface.
if(this->IsImported())
{
return this->Target->GetImportLinkInterface(config, head, false);
}
// Link interfaces are not supported for executables that do not
// export symbols.
if(this->GetType() == cmTarget::EXECUTABLE &&
!this->Target->IsExecutableWithExports())
{
return 0;
}
// Lookup any existing link interface for this configuration.
cmHeadToLinkInterfaceMap& hm =
this->Target->GetHeadToLinkInterfaceMap(config);
// If the link interface does not depend on the head target
// then return the one we computed first.
if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
{
return &hm.begin()->second;
}
cmOptionalLinkInterface& iface = hm[head];
if(!iface.LibrariesDone)
{
iface.LibrariesDone = true;
this->Target->ComputeLinkInterfaceLibraries(
config, iface, head, false);
}
if(!iface.AllDone)
{
iface.AllDone = true;
if(iface.Exists)
{
this->Target->ComputeLinkInterface(config, iface, head);
}
}
return iface.Exists? &iface : 0;
}

View File

@ -12,7 +12,7 @@
#ifndef cmGeneratorTarget_h
#define cmGeneratorTarget_h
#include "cmStandardIncludes.h"
#include "cmLinkItem.h"
class cmCustomCommand;
class cmGlobalGenerator;
@ -106,6 +106,8 @@ public:
const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
const std::string& config) const;
cmLinkInterface const* GetLinkInterface(const std::string& config,
cmTarget const* headTarget) const;
/** Get the full path to the target according to the settings in its
makefile and the configuration type. */

View File

@ -4107,53 +4107,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
}
}
//----------------------------------------------------------------------------
cmLinkInterface const* cmTarget::GetLinkInterface(const std::string& config,
cmTarget const* head) const
{
// Imported targets have their own link interface.
if(this->IsImported())
{
return this->GetImportLinkInterface(config, head, false);
}
// Link interfaces are not supported for executables that do not
// export symbols.
if(this->GetType() == cmTarget::EXECUTABLE &&
!this->IsExecutableWithExports())
{
return 0;
}
// Lookup any existing link interface for this configuration.
cmHeadToLinkInterfaceMap& hm = this->GetHeadToLinkInterfaceMap(config);
// If the link interface does not depend on the head target
// then return the one we computed first.
if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
{
return &hm.begin()->second;
}
cmOptionalLinkInterface& iface = hm[head];
if(!iface.LibrariesDone)
{
iface.LibrariesDone = true;
this->ComputeLinkInterfaceLibraries(
config, iface, head, false);
}
if(!iface.AllDone)
{
iface.AllDone = true;
if(iface.Exists)
{
this->ComputeLinkInterface(config, iface, head);
}
}
return iface.Exists? &iface : 0;
}
//----------------------------------------------------------------------------
const cmLinkInterfaceLibraries *
cmTarget::GetLinkInterfaceLibraries(const std::string& config,

View File

@ -241,10 +241,6 @@ public:
cmTarget const* head,
bool usage_requirements_only) const;
/** Get the link interface for the given configuration. Returns 0
if the target cannot be linked. */
cmLinkInterface const* GetLinkInterface(const std::string& config,
cmTarget const* headTarget) const;
cmLinkInterfaceLibraries const*
GetLinkInterfaceLibraries(const std::string& config,
cmTarget const* headTarget,