diff options
author | Brad King <brad.king@kitware.com> | 2008-01-28 13:38:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-28 13:38:36 (GMT) |
commit | 5594ad488576a77d9c6b8c3c1999a04fb4e6867d (patch) | |
tree | f22726476b6eaaf3832e48c185fe3c112601db17 /Source/cmComputeLinkDepends.cxx | |
parent | a7cb9d1120c0555f1da67dd585bd1b4fd16d389d (diff) | |
download | CMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.zip CMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.tar.gz CMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.tar.bz2 |
ENH: Updated exporting and importing of targets to support libraries and configurations.
- Created cmExportFileGenerator hierarchy to implement export file generation
- Installed exports use per-config import files loaded by a central one.
- Include soname of shared libraries in import information
- Renamed PREFIX to NAMESPACE in INSTALL(EXPORT) and EXPORT() commands
- Move addition of CMAKE_INSTALL_PREFIX to destinations to install generators
- Import files compute the installation prefix relative to their location when loaded
- Add mapping of importer configurations to importee configurations
- Rename IMPORT targets to IMPORTED targets to distinguish from windows import libraries
- Scope IMPORTED targets within directories to isolate them
- Place all properties created by import files in the IMPORTED namespace
- Document INSTALL(EXPORT) and EXPORT() commands.
- Document IMPORTED signature of add_executable and add_library
- Enable finding of imported targets in cmComputeLinkDepends
Diffstat (limited to 'Source/cmComputeLinkDepends.cxx')
-rw-r--r-- | Source/cmComputeLinkDepends.cxx | 93 |
1 files changed, 70 insertions, 23 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 6056431..b4cb92e 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -158,7 +158,7 @@ std::vector<cmComputeLinkDepends::LinkEntry> const& cmComputeLinkDepends::Compute() { // Follow the link dependencies of the target to be linked. - this->AddLinkEntries(-1, this->Target->GetOriginalLinkLibraries()); + this->AddTargetLinkEntries(-1, this->Target->GetOriginalLinkLibraries()); // Complete the breadth-first search of dependencies. while(!this->BFSQueue.empty()) @@ -222,8 +222,7 @@ int cmComputeLinkDepends::AddLinkEntry(std::string const& item) int index = lei->second; LinkEntry& entry = this->EntryList[index]; entry.Item = item; - entry.Target = - this->GlobalGenerator->FindTarget(0, entry.Item.c_str(), false); + entry.Target = this->Makefile->FindTargetToUse(entry.Item.c_str()); // If the item has dependencies queue it to follow them. if(entry.Target) @@ -264,8 +263,15 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(entry.Target) { // Follow the target dependencies. - this->AddLinkEntries(depender_index, - entry.Target->GetOriginalLinkLibraries()); + if(entry.Target->IsImported()) + { + this->AddImportedLinkEntries(depender_index, entry.Target); + } + else + { + this->AddTargetLinkEntries(depender_index, + entry.Target->GetOriginalLinkLibraries()); + } } else { @@ -274,6 +280,18 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) } } +//---------------------------------------------------------------------------- +void cmComputeLinkDepends::AddImportedLinkEntries(int depender_index, + cmTarget* target) +{ + if(std::vector<std::string> const* libs = + target->GetImportedLinkLibraries(this->Config)) + { + this->AddLinkEntries(depender_index, *libs); + } +} + +//---------------------------------------------------------------------------- void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, const char* value) { @@ -283,39 +301,49 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, std::vector<std::string> deplist; cmSystemTools::ExpandListArgument(value, deplist); - // Construct the vector of type/value pairs from the variable. - LinkLibraryVectorType libs; - cmTarget::LinkLibraryType linkType = cmTarget::GENERAL; + // Compute which library configuration to link. + cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED; + if(this->Config && cmSystemTools::UpperCase(this->Config) == "DEBUG") + { + linkType = cmTarget::DEBUG; + } + + // Look for entries meant for this configuration. + std::vector<std::string> actual_libs; + cmTarget::LinkLibraryType llt = cmTarget::GENERAL; for(std::vector<std::string>::const_iterator di = deplist.begin(); di != deplist.end(); ++di) { if(*di == "debug") { - linkType = cmTarget::DEBUG; + llt = cmTarget::DEBUG; } else if(*di == "optimized") { - linkType = cmTarget::OPTIMIZED; + llt = cmTarget::OPTIMIZED; } else if(*di == "general") { - linkType = cmTarget::GENERAL; + llt = cmTarget::GENERAL; } else if(!di->empty()) { - cmTarget::LibraryID lib(*di, linkType); - libs.push_back(lib); + if(llt == cmTarget::GENERAL || llt == linkType) + { + actual_libs.push_back(*di); + } linkType = cmTarget::GENERAL; } } // Add the entries from this list. - this->AddLinkEntries(depender_index, libs); + this->AddLinkEntries(depender_index, actual_libs); } //---------------------------------------------------------------------------- -void cmComputeLinkDepends::AddLinkEntries(int depender_index, - LinkLibraryVectorType const& libs) +void +cmComputeLinkDepends::AddTargetLinkEntries(int depender_index, + LinkLibraryVectorType const& libs) { // Compute which library configuration to link. cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED; @@ -324,23 +352,42 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, linkType = cmTarget::DEBUG; } + // Look for entries meant for this configuration. + std::vector<std::string> actual_libs; + for(cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin(); + li != libs.end(); ++li) + { + if(li->second == cmTarget::GENERAL || li->second == linkType) + { + actual_libs.push_back(li->first); + } + } + + // Add these entries. + this->AddLinkEntries(depender_index, actual_libs); +} + +//---------------------------------------------------------------------------- +void +cmComputeLinkDepends::AddLinkEntries(int depender_index, + std::vector<std::string> const& libs) +{ // Track inferred dependency sets implied by this list. std::map<int, DependSet> dependSets; - // Loop over the libraries linked directly by the target. - for(cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin(); + // Loop over the libraries linked directly by the depender. + for(std::vector<std::string>::const_iterator li = libs.begin(); li != libs.end(); ++li) { - // Skip entries that will resolve to the target getting linked. - // Skip libraries not meant for the current configuration. - if(li->first == this->Target->GetName() || li->first.empty() || - !(li->second == cmTarget::GENERAL || li->second == linkType)) + // Skip entries that will resolve to the target getting linked or + // are empty. + if(*li == this->Target->GetName() || li->empty()) { continue; } // Add a link entry for this item. - int dependee_index = this->AddLinkEntry(li->first); + int dependee_index = this->AddLinkEntry(*li); // The depender must come before the dependee. if(depender_index >= 0) |