diff options
author | Brad King <brad.king@kitware.com> | 2008-01-31 12:50:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-31 12:50:40 (GMT) |
commit | 3a05425309dd19f4c91febdf96b4ac3fc1d17ce5 (patch) | |
tree | 4f14c27a2a15110486bb93ade1c50b17154ee977 /Source/cmComputeLinkInformation.cxx | |
parent | 73a5f0846f4946d74bbe7822fdf5458481e03362 (diff) | |
download | CMake-3a05425309dd19f4c91febdf96b4ac3fc1d17ce5.zip CMake-3a05425309dd19f4c91febdf96b4ac3fc1d17ce5.tar.gz CMake-3a05425309dd19f4c91febdf96b4ac3fc1d17ce5.tar.bz2 |
BUG: Move decision to switch library paths found in implicit link directories to use -l options from cmFindLibraryCommand to cmComputeLinkInformation. Existing projects may depend on find_library returning a full path. This slightly weakens cmComputeLinkInformation but is necessary for compatibility.
Diffstat (limited to 'Source/cmComputeLinkInformation.cxx')
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 990b8e5..1e340c0 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -234,6 +234,21 @@ cmComputeLinkInformation // Setup framework support. this->ComputeFrameworkInfo(); + // Get the implicit link directories for this platform. + if(const char* implicitLinks = + (this->Makefile->GetDefinition + ("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES"))) + { + std::vector<std::string> implicitLinkVec; + cmSystemTools::ExpandListArgument(implicitLinks, implicitLinkVec); + for(std::vector<std::string>::const_iterator + i = implicitLinkVec.begin(); + i != implicitLinkVec.end(); ++i) + { + this->ImplicitLinkDirs.insert(*i); + } + } + // Initial state. this->RuntimeSearchPathComputed = false; this->HaveUserFlagItem = false; @@ -689,6 +704,12 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item, //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddFullItem(std::string const& item) { + // Check for the implicit link directory special case. + if(this->CheckImplicitDirItem(item)) + { + return; + } + // This is called to handle a link item that is a full path. // If the target is not a static library make sure the link type is // shared. This is because dynamic-mode linking can handle both @@ -728,6 +749,37 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) } //---------------------------------------------------------------------------- +bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) +{ + // We only switch to a pathless item if the link type may be + // enforced. Fortunately only platforms that support link types + // seem to have magic per-architecture implicit link directories. + if(!this->LinkTypeEnabled) + { + return false; + } + + // Check if this item is in an implicit link directory. + std::string dir = cmSystemTools::GetFilenamePath(item); + if(this->ImplicitLinkDirs.find(dir) == this->ImplicitLinkDirs.end()) + { + // Only libraries in implicit link directories are converted to + // pathless items. + return false; + } + + // Many system linkers support multiple architectures by + // automatically selecting the implicit linker search path for the + // current architecture. If the library appears in an implicit link + // directory then just report the file name without the directory + // portion. This will allow the system linker to locate the proper + // library for the architecture at link time. + std::string file = cmSystemTools::GetFilenameName(item); + this->AddUserItem(file); + return true; +} + +//---------------------------------------------------------------------------- void cmComputeLinkInformation::AddUserItem(std::string const& item) { // This is called to handle a link item that does not match a CMake @@ -907,20 +959,8 @@ void cmComputeLinkInformation::AddFrameworkPath(std::string const& p) void cmComputeLinkInformation::ComputeLinkerSearchDirectories() { // Some search paths should never be emitted. + this->DirectoriesEmmitted = this->ImplicitLinkDirs; this->DirectoriesEmmitted.insert(""); - if(const char* implicitLinks = - (this->Makefile->GetDefinition - ("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES"))) - { - std::vector<std::string> implicitLinkVec; - cmSystemTools::ExpandListArgument(implicitLinks, implicitLinkVec); - for(std::vector<std::string>::const_iterator - i = implicitLinkVec.begin(); - i != implicitLinkVec.end(); ++i) - { - this->DirectoriesEmmitted.insert(*i); - } - } // Check if we need to include the runtime search path at link time. std::string var = "CMAKE_SHARED_LIBRARY_LINK_"; |