From 84b847e42fde288bc102198aedeb68e19b41ef1e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Aug 2015 19:38:14 +0200 Subject: [PATCH] cmGeneratorTarget: Move ComputeLinkInterface from cmTarget. --- Source/cmGeneratorTarget.cxx | 100 ++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 3 ++ Source/cmTarget.cxx | 97 --------------------------------- Source/cmTarget.h | 3 -- 4 files changed, 102 insertions(+), 101 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5d843098e..058a12064 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3399,9 +3399,107 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, iface.AllDone = true; if(iface.Exists) { - this->Target->ComputeLinkInterface(config, iface, head); + this->ComputeLinkInterface(config, iface, head); } } return iface.Exists? &iface : 0; } + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, + cmOptionalLinkInterface &iface, + cmTarget const* headTarget) const +{ + if(iface.ExplicitLibraries) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY + || this->GetType() == cmTarget::STATIC_LIBRARY + || this->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + UNORDERED_SET emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(li->Target) + { + // This is a runtime dependency on another shared library. + if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + } + } + } + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* + impl = this->Target->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + } + + if(this->Target->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + if(cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config)) + { + iface.Languages = impl->Languages; + } + } + + if(this->GetType() == cmTarget::STATIC_LIBRARY) + { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // How many repetitions are needed if this library has cyclic + // dependencies? + std::string propName = "LINK_INTERFACE_MULTIPLICITY"; + propName += suffix; + if(const char* config_reps = this->GetProperty(propName)) + { + sscanf(config_reps, "%u", &iface.Multiplicity); + } + else if(const char* reps = + this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &iface.Multiplicity); + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2dbb502e8..282ab8997 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -108,6 +108,9 @@ public: cmLinkInterface const* GetLinkInterface(const std::string& config, cmTarget const* headTarget) const; + void ComputeLinkInterface(const std::string& config, + cmOptionalLinkInterface& iface, + cmTarget const* head) 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 ee298acad..c8a91482a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4358,103 +4358,6 @@ cmTarget::ComputeLinkInterfaceLibraries( } } -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkInterface(const std::string& config, - cmOptionalLinkInterface &iface, - cmTarget const* headTarget) const -{ - if(iface.ExplicitLibraries) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - UNORDERED_SET emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmTarget::LinkImplementation const* impl = - this->GetLinkImplementation(config); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(li->Target) - { - // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - } - } - } - else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* - impl = this->GetLinkImplementationLibrariesInternal(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - } - - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = - this->GetLinkImplementation(config)) - { - iface.Languages = impl->Languages; - } - } - - if(this->GetType() == cmTarget::STATIC_LIBRARY) - { - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // How many repetitions are needed if this library has cyclic - // dependencies? - std::string propName = "LINK_INTERFACE_MULTIPLICITY"; - propName += suffix; - if(const char* config_reps = this->GetProperty(propName)) - { - sscanf(config_reps, "%u", &iface.Multiplicity); - } - else if(const char* reps = - this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &iface.Multiplicity); - } - } -} //---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a8c6e8fd3..e71820e6c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,9 +233,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - void ComputeLinkInterface(const std::string& config, - cmOptionalLinkInterface& iface, - cmTarget const* head) const; void ComputeLinkInterfaceLibraries(const std::string& config, cmOptionalLinkInterface &iface, cmTarget const* head,