From 6220241fd0bb7902c932742a7aa3d6a96fd0e919 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Aug 2015 19:37:45 +0200 Subject: [PATCH] cmGeneratorTarget: Move GetLinkInterface from cmTarget. --- Source/cmComputeLinkDepends.cxx | 12 +++++-- Source/cmComputeTargetDepends.cxx | 2 +- Source/cmExportFileGenerator.cxx | 8 ++--- Source/cmGeneratorTarget.cxx | 55 +++++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 4 ++- Source/cmTarget.cxx | 47 -------------------------- Source/cmTarget.h | 4 --- 7 files changed, 69 insertions(+), 63 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 03ec8200d..5e9627bd4 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -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) { diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index aeb918441..83b2a0ede 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -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::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index d559a0748..9a7d73f4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,9 +796,8 @@ cmExportFileGenerator std::vector& 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", diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 06a4c6a0f..5d843098e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -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::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; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 15b333566..2dbb502e8 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -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. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb545b102..ee298acad 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -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, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 53a8bd643..a8c6e8fd3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -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,