diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-08-04 17:19:43 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-08-05 16:20:45 (GMT) |
commit | 5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6 (patch) | |
tree | cbffae918664d4c8ddd0b605585916d79643ee0d /Source/cmTarget.cxx | |
parent | 38d4ba3564b9a37f8042888ffd63bf736852b6b8 (diff) | |
download | CMake-5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6.zip CMake-5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6.tar.gz CMake-5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6.tar.bz2 |
cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 399 |
1 files changed, 0 insertions, 399 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template<typename PropertyType> -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty<bool>(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty<const char *>(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template<typename PropertyType> -std::pair<bool, PropertyType> consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair<bool, bool> consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair<bool, const char*> consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair<bool, const char*> consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair<bool, const char*>(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair<bool, const char*>(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair<bool, const char*> consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair<bool, const char*>(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair<bool, const char*>(false, null_ptr); -} - -template<typename PropertyType> -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue<bool>(bool) -{ - return false; -} -template<> -const char* impliedValue<const char*>(const char*) -{ - return ""; -} - - -template<typename PropertyType> -std::string valueAsString(PropertyType); -template<> -std::string valueAsString<bool>(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString<const char*>(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template<typename PropertyType> -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty<PropertyType>(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector<cmTarget const*> const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString<PropertyType>(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector<cmTarget const*>::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty<PropertyType>(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString<PropertyType>(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair<bool, PropertyType> consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue<PropertyType>(propContent); - - if (ifaceIsSet) - { - std::pair<bool, PropertyType> consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair<bool, PropertyType> consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString<PropertyType>(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility<const char *>(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility<const char *>(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility<const char *>(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const { |