diff options
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 158 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 6 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 153 | ||||
-rw-r--r-- | Source/cmTarget.h | 5 |
4 files changed, 161 insertions, 161 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2489c99..40a3637 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -230,7 +230,8 @@ struct TagVisitor //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), - SourceFileFlagsConstructed(false) + SourceFileFlagsConstructed(false), + PolicyWarnedCMP0022(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -3395,7 +3396,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, if(!iface.LibrariesDone) { iface.LibrariesDone = true; - this->Target->ComputeLinkInterfaceLibraries( + this->ComputeLinkInterfaceLibraries( config, iface, head, false); } if(!iface.AllDone) @@ -3547,9 +3548,160 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, if(!iface.LibrariesDone) { iface.LibrariesDone = true; - this->Target->ComputeLinkInterfaceLibraries( + this->ComputeLinkInterfaceLibraries( config, iface, head, usage_requirements_only); } return iface.Exists? &iface : 0; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ComputeLinkInterfaceLibraries( + const std::string& config, + cmOptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // An explicit list of interface libraries may be set for shared + // libraries and executables that export symbols. + const char* explicitLibraries = 0; + std::string linkIfaceProp; + if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = this->GetProperty(linkIfaceProp); + } + else if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->Target->IsExecutableWithExports()) + { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + + // Lookup the per-configuration property. + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = this->GetProperty(linkIfaceProp); + + // If not set, try the generic property. + if(!explicitLibraries) + { + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = this->GetProperty(linkIfaceProp); + } + } + + if(explicitLibraries && + this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) + { + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + this->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << this->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + if(!explicitLibraries && + (this->GetType() == cmTarget::EXECUTABLE || + (this->GetType() == cmTarget::MODULE_LIBRARY))) + { + return; + } + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; + + if(explicitLibraries) + { + // The interface libraries have been explicitly set. + this->Target->ExpandLinkItems(linkIfaceProp, explicitLibraries, + config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + } + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); + if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + std::vector<cmLinkItem> ifaceLibs; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; + if(const char* newExplicitLibraries = this->GetProperty(newProp)) + { + bool hadHeadSensitiveConditionDummy = false; + this->Target->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); + } + if (ifaceLibs != iface.Libraries) + { + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << this->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 43fcb4a..ac2b96c 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -117,6 +117,11 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; + void ComputeLinkInterfaceLibraries(const std::string& config, + cmOptionalLinkInterface &iface, + cmTarget const* head, + bool usage_requirements_only) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -388,6 +393,7 @@ private: typedef std::pair<std::string, bool> OutputNameKey; typedef std::map<OutputNameKey, std::string> OutputNameMapType; mutable OutputNameMapType OutputNameMap; + mutable bool PolicyWarnedCMP0022; public: std::vector<cmTarget const*> const& diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 00dbc6a..9e9aed4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -77,13 +77,11 @@ public: cmTargetInternals() : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -95,7 +93,6 @@ public: LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - bool PolicyWarnedCMP0022; typedef std::map<std::string, cmTarget::OutputInfo> OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -4166,156 +4163,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void -cmTarget::ComputeLinkInterfaceLibraries( - const std::string& config, - cmOptionalLinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // An explicit list of interface libraries may be set for shared - // libraries and executables that export symbols. - const char* explicitLibraries = 0; - std::string linkIfaceProp; - if(this->GetPolicyStatusCMP0022() != cmPolicies::OLD && - this->GetPolicyStatusCMP0022() != cmPolicies::WARN) - { - // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp); - } - else if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->IsExecutableWithExports()) - { - // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a - // shared lib or executable. - - // Lookup the per-configuration property. - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - linkIfaceProp += suffix; - explicitLibraries = this->GetProperty(linkIfaceProp); - - // If not set, try the generic property. - if(!explicitLibraries) - { - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp); - } - } - - if(explicitLibraries && - this->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->Internal->PolicyWarnedCMP0022) - { - // Compare the explicitly set old link interface properties to the - // preferred new link interface property one and warn if different. - const char* newExplicitLibraries = - this->GetProperty("INTERFACE_LINK_LIBRARIES"); - if (newExplicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property which differs from its " << - linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newExplicitLibraries << "\n" << - linkIfaceProp << ":\n" - " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->Internal->PolicyWarnedCMP0022 = true; - } - } - - // There is no implicit link interface for executables or modules - // so if none was explicitly set then there is no link interface. - if(!explicitLibraries && - (this->GetType() == cmTarget::EXECUTABLE || - (this->GetType() == cmTarget::MODULE_LIBRARY))) - { - return; - } - iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; - - if(explicitLibraries) - { - // The interface libraries have been explicitly set. - this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - } - else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibrariesInternal(config, headTarget); - iface.Libraries.insert(iface.Libraries.end(), - impl->Libraries.begin(), impl->Libraries.end()); - if(this->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->Internal->PolicyWarnedCMP0022 && !usage_requirements_only) - { - // Compare the link implementation fallback link interface to the - // preferred new link interface property and warn if different. - std::vector<cmLinkItem> ifaceLibs; - static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = this->GetProperty(newProp)) - { - bool hadHeadSensitiveConditionDummy = false; - this->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); - } - if (ifaceLibs != iface.Libraries) - { - std::string oldLibraries = cmJoin(impl->Libraries, ";"); - std::string newLibraries = cmJoin(ifaceLibs, ";"); - if(oldLibraries.empty()) - { oldLibraries = "(empty)"; } - if(newLibraries.empty()) - { newLibraries = "(empty)"; } - - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property. " - "This should be preferred as the source of the link interface " - "for this library but because CMP0022 is not set CMake is " - "ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newLibraries << "\n" - "Link implementation:\n" - " " << oldLibraries << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->Internal->PolicyWarnedCMP0022 = true; - } - } - } -} - - -//---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector<TargetPropertyEntry*>& entries) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f124084..985e958 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,11 +233,6 @@ public: void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const; - void ComputeLinkInterfaceLibraries(const std::string& config, - cmOptionalLinkInterface &iface, - cmTarget const* head, - bool usage_requirements_only) const; - cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceMap(std::string const& config) const; cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( |