diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-10-16 17:19:50 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-10-16 18:24:43 (GMT) |
commit | 8f363d6771dfa792d606978e1e406229637078f6 (patch) | |
tree | 2df476b2fe5383b331fbf1f54dddc9e03c3b0d6a /Source/cmGeneratorTarget.cxx | |
parent | 5794dbc301ace0041c5fc50096cc5331e8ba3c34 (diff) | |
download | CMake-8f363d6771dfa792d606978e1e406229637078f6.zip CMake-8f363d6771dfa792d606978e1e406229637078f6.tar.gz CMake-8f363d6771dfa792d606978e1e406229637078f6.tar.bz2 |
cmGeneratorTarget: Move ImportInfo from cmTarget.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 228 |
1 files changed, 224 insertions, 4 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2ef2f5c..87a75b4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1364,7 +1364,8 @@ bool cmGeneratorTarget::IsImportedSharedLibWithoutSOName( { if(this->IsImported() && this->GetType() == cmState::SHARED_LIBRARY) { - if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) { return info->NoSOName; } @@ -1405,7 +1406,8 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir( else { // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) { if(!info->NoSOName && !info->SOName.empty()) { @@ -1492,7 +1494,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const if(this->Target->IsImported()) { // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) { if(info->NoSOName) { @@ -5080,7 +5083,7 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, cmGeneratorTarget const* headTarget, bool usage_requirements_only) const { - cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); + cmGeneratorTarget::ImportInfo const* info = this->GetImportInfo(config); if(!info) { return 0; @@ -5118,6 +5121,223 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, return &iface; } +//---------------------------------------------------------------------------- +cmGeneratorTarget::ImportInfo const* +cmGeneratorTarget::GetImportInfo(const std::string& config) const +{ + // There is no imported information for non-imported targets. + if(!this->IsImported()) + { + return 0; + } + + // Lookup/compute/cache the import information for this + // configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + else + { + config_upper = "NOCONFIG"; + } + + ImportInfoMapType::const_iterator i = + this->ImportInfoMap.find(config_upper); + if(i == this->ImportInfoMap.end()) + { + ImportInfo info; + this->ComputeImportInfo(config_upper, info); + ImportInfoMapType::value_type entry(config_upper, info); + i = this->ImportInfoMap.insert(entry).first; + } + + if(this->GetType() == cmState::INTERFACE_LIBRARY) + { + return &i->second; + } + // If the location is empty then the target is not available for + // this configuration. + if(i->second.Location.empty() && i->second.ImportLibrary.empty()) + { + return 0; + } + + // Return the import information. + return &i->second; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, + ImportInfo& info) const +{ + // This method finds information about an imported target from its + // properties. The "IMPORTED_" namespace is reserved for properties + // defined by the project exporting the target. + + // Initialize members. + info.NoSOName = false; + + const char* loc = 0; + const char* imp = 0; + std::string suffix; + if (!this->Target->GetMappedConfig(desired_config, &loc, &imp, suffix)) + { + return; + } + + // Get the link interface. + { + std::string linkProp = "INTERFACE_LINK_LIBRARIES"; + const char *propertyLibs = this->GetProperty(linkProp); + + if (this->GetType() != cmState::INTERFACE_LIBRARY) + { + if(!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + linkProp += suffix; + propertyLibs = this->GetProperty(linkProp); + } + + if(!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + propertyLibs = this->GetProperty(linkProp); + } + } + if(propertyLibs) + { + info.LibrariesProp = linkProp; + info.Libraries = propertyLibs; + } + } + if(this->GetType() == cmState::INTERFACE_LIBRARY) + { + return; + } + + // A provided configuration has been chosen. Load the + // configuration's properties. + + // Get the location. + if(loc) + { + info.Location = loc; + } + else + { + std::string impProp = "IMPORTED_LOCATION"; + impProp += suffix; + if(const char* config_location = this->GetProperty(impProp)) + { + info.Location = config_location; + } + else if(const char* location = this->GetProperty("IMPORTED_LOCATION")) + { + info.Location = location; + } + } + + // Get the soname. + if(this->GetType() == cmState::SHARED_LIBRARY) + { + std::string soProp = "IMPORTED_SONAME"; + soProp += suffix; + if(const char* config_soname = this->GetProperty(soProp)) + { + info.SOName = config_soname; + } + else if(const char* soname = this->GetProperty("IMPORTED_SONAME")) + { + info.SOName = soname; + } + } + + // Get the "no-soname" mark. + if(this->GetType() == cmState::SHARED_LIBRARY) + { + std::string soProp = "IMPORTED_NO_SONAME"; + soProp += suffix; + if(const char* config_no_soname = this->GetProperty(soProp)) + { + info.NoSOName = cmSystemTools::IsOn(config_no_soname); + } + else if(const char* no_soname = this->GetProperty("IMPORTED_NO_SONAME")) + { + info.NoSOName = cmSystemTools::IsOn(no_soname); + } + } + + // Get the import library. + if(imp) + { + info.ImportLibrary = imp; + } + else if(this->GetType() == cmState::SHARED_LIBRARY || + this->Target->IsExecutableWithExports()) + { + std::string impProp = "IMPORTED_IMPLIB"; + impProp += suffix; + if(const char* config_implib = this->GetProperty(impProp)) + { + info.ImportLibrary = config_implib; + } + else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB")) + { + info.ImportLibrary = implib; + } + } + + // Get the link dependencies. + { + std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES"; + linkProp += suffix; + if(const char* config_libs = this->GetProperty(linkProp)) + { + info.SharedDeps = config_libs; + } + else if(const char* libs = + this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) + { + info.SharedDeps = libs; + } + } + + // Get the link languages. + if(this->Target->LinkLanguagePropagatesToDependents()) + { + std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES"; + linkProp += suffix; + if(const char* config_libs = this->GetProperty(linkProp)) + { + info.Languages = config_libs; + } + else if(const char* libs = + this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) + { + info.Languages = libs; + } + } + + // Get the cyclic repetition count. + if(this->GetType() == cmState::STATIC_LIBRARY) + { + std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; + linkProp += suffix; + if(const char* config_reps = this->GetProperty(linkProp)) + { + sscanf(config_reps, "%u", &info.Multiplicity); + } + else if(const char* reps = + this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &info.Multiplicity); + } + } +} + cmHeadToLinkInterfaceMap& cmGeneratorTarget::GetHeadToLinkInterfaceMap(const std::string &config) const { |