From 2cb3e5740269757f6f93d24a4d13570ee72de318 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Aug 2015 19:39:17 +0200 Subject: [PATCH] cmGeneratorTarget: Move GetImportLinkInterface from cmTarget. --- Source/cmGeneratorTarget.cxx | 69 +++++++++++++++++++++++++++++++++--- Source/cmGeneratorTarget.h | 14 ++++++++ Source/cmTarget.cxx | 65 --------------------------------- Source/cmTarget.h | 10 ------ 4 files changed, 78 insertions(+), 80 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 40a36378e5..c966e24802 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3370,7 +3370,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, // Imported targets have their own link interface. if(this->IsImported()) { - return this->Target->GetImportLinkInterface(config, head, false); + return this->GetImportLinkInterface(config, head, false); } // Link interfaces are not supported for executables that do not @@ -3383,7 +3383,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, // Lookup any existing link interface for this configuration. cmHeadToLinkInterfaceMap& hm = - this->Target->GetHeadToLinkInterfaceMap(config); + this->GetHeadToLinkInterfaceMap(config); // If the link interface does not depend on the head target // then return the one we computed first. @@ -3518,7 +3518,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, // Imported targets have their own link interface. if(this->IsImported()) { - return this->Target->GetImportLinkInterface(config, head, + return this->GetImportLinkInterface(config, head, usage_requirements_only); } @@ -3534,8 +3534,8 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, std::string CONFIG = cmSystemTools::UpperCase(config); cmHeadToLinkInterfaceMap& hm = (usage_requirements_only ? - this->Target->GetHeadToLinkInterfaceUsageRequirementsMap(config) : - this->Target->GetHeadToLinkInterfaceMap(config)); + this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : + this->GetHeadToLinkInterfaceMap(config)); // If the link interface does not depend on the head target // then return the one we computed first. @@ -3705,3 +3705,62 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( } } } + +//---------------------------------------------------------------------------- +const cmLinkInterface * +cmGeneratorTarget::GetImportLinkInterface(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); + if(!info) + { + return 0; + } + + std::string CONFIG = cmSystemTools::UpperCase(config); + cmHeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : + 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[headTarget]; + if(!iface.AllDone) + { + iface.AllDone = true; + iface.Multiplicity = info->Multiplicity; + cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, + config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + std::vector deps; + cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + this->Target->LookupLinkItems(deps, iface.SharedDeps); + } + + return &iface; +} + +cmHeadToLinkInterfaceMap& +cmGeneratorTarget::GetHeadToLinkInterfaceMap(const std::string &config) const +{ + std::string CONFIG = cmSystemTools::UpperCase(config); + return this->LinkInterfaceMap[CONFIG]; +} + +cmHeadToLinkInterfaceMap& +cmGeneratorTarget::GetHeadToLinkInterfaceUsageRequirementsMap( + const std::string &config) const +{ + std::string CONFIG = cmSystemTools::UpperCase(config); + return this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG]; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ac2b96cc76..9c5adf6540 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -390,6 +390,20 @@ private: }; mutable std::map LinkImplClosureMap; + typedef std::map + LinkInterfaceMapType; + mutable LinkInterfaceMapType LinkInterfaceMap; + mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; + + cmHeadToLinkInterfaceMap& + GetHeadToLinkInterfaceMap(std::string const& config) const; + cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( + std::string const& config) const; + + cmLinkInterface const* + GetImportLinkInterface(const std::string& config, cmTarget const* head, + bool usage_requirements_only) const; + typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9e9aed4e27..86285837c3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -89,11 +89,6 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; - typedef std::map - LinkInterfaceMapType; - LinkInterfaceMapType LinkInterfaceMap; - LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -510,8 +505,6 @@ void cmTarget::ClearLinkMaps() { this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); - this->Internal->LinkInterfaceMap.clear(); - this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -4104,64 +4097,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } } -cmHeadToLinkInterfaceMap& -cmTarget::GetHeadToLinkInterfaceMap(const std::string &config) const -{ - std::string CONFIG = cmSystemTools::UpperCase(config); - return this->Internal->LinkInterfaceMap[CONFIG]; -} - -cmHeadToLinkInterfaceMap& -cmTarget::GetHeadToLinkInterfaceUsageRequirementsMap( - const std::string &config) const -{ - std::string CONFIG = cmSystemTools::UpperCase(config); - return this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG]; -} - -//---------------------------------------------------------------------------- -const cmLinkInterface * -cmTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - cmTarget::ImportInfo const* info = this->GetImportInfo(config); - if(!info) - { - return 0; - } - - std::string CONFIG = cmSystemTools::UpperCase(config); - cmHeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : - 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[headTarget]; - if(!iface.AllDone) - { - iface.AllDone = true; - iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->LookupLinkItems(deps, iface.SharedDeps); - } - - return &iface; -} - //---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 985e958702..25de6a659d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,11 +233,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmHeadToLinkInterfaceMap& - GetHeadToLinkInterfaceMap(std::string const& config) const; - cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( - std::string const& config) const; - struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. @@ -559,11 +554,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - - cmLinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, - bool usage_requirements_only) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const;