diff options
author | Brad King <brad.king@kitware.com> | 2013-02-15 18:12:31 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-02-15 18:12:31 (GMT) |
commit | e85f1c28d4e709bf468cd1d146f71d528f408582 (patch) | |
tree | 307f320ee0860b044eeee125c70b3e56eb20a9dd | |
parent | ffdf57d9f5f0fc6c64e3c4ec32cc7630576770ab (diff) | |
parent | 95a9c80cacea50e2b5d52d67d0a7f5c9b50192dd (diff) | |
download | CMake-e85f1c28d4e709bf468cd1d146f71d528f408582.zip CMake-e85f1c28d4e709bf468cd1d146f71d528f408582.tar.gz CMake-e85f1c28d4e709bf468cd1d146f71d528f408582.tar.bz2 |
Merge topic 'rpath-use-implicit-link-dirs'
95a9c80 Merge topic 'LINK_LIBRARIES-property' into rpath-use-implicit-link-dirs
baa33ac AIX-GNU: Put implicit link directories in runtime libpath (#13909)
171b099 Avoid duplicate RPATH entries
-rw-r--r-- | Modules/Platform/AIX-GNU.cmake | 1 | ||||
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 53 | ||||
-rw-r--r-- | Source/cmDocumentVariables.cxx | 3 |
3 files changed, 53 insertions, 4 deletions
diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index 81ba365..a73a7a2 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -23,4 +23,5 @@ macro(__aix_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,-G,-brtl,-bnoipath") set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-brtl,-bnoipath,-bexpall") # +s, flag for exe link to use shared lib + set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1) endmacro() diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 08cdcb5..84714f3 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1784,6 +1784,22 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath) } //---------------------------------------------------------------------------- +static void cmCLI_ExpandListUnique(const char* str, + std::vector<std::string>& out, + std::set<cmStdString>& emitted) +{ + std::vector<std::string> tmp; + cmSystemTools::ExpandListArgument(str, tmp); + for(std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end(); ++i) + { + if(emitted.insert(*i).second) + { + out.push_back(*i); + } + } +} + +//---------------------------------------------------------------------------- void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, bool for_install) { @@ -1808,10 +1824,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. + std::set<cmStdString> emitted; if(use_install_rpath) { const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); - cmSystemTools::ExpandListArgument(install_rpath, runtimeDirs); + cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) { @@ -1823,7 +1840,10 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // support or if using the link path as an rpath. if(use_build_rpath) { - runtimeDirs.push_back(*ri); + if(emitted.insert(*ri).second) + { + runtimeDirs.push_back(*ri); + } } else if(use_link_rpath) { @@ -1835,15 +1855,40 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) { - runtimeDirs.push_back(*ri); + if(emitted.insert(*ri).second) + { + runtimeDirs.push_back(*ri); + } } } } } + // Add runtime paths required by the languages to always be + // present. This is done even when skipping rpath support. + { + cmTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config, this->HeadTarget); + for(std::vector<std::string>::const_iterator li = lc->Languages.begin(); + li != lc->Languages.end(); ++li) + { + std::string useVar = "CMAKE_" + *li + + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH"; + if(this->Makefile->IsOn(useVar.c_str())) + { + std::string dirVar = "CMAKE_" + *li + + "_IMPLICIT_LINK_DIRECTORIES"; + if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str())) + { + cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted); + } + } + } + } + // Add runtime paths required by the platform to always be // present. This is done even when skipping rpath support. - cmSystemTools::ExpandListArgument(this->RuntimeAlways.c_str(), runtimeDirs); + cmCLI_ExpandListUnique(this->RuntimeAlways.c_str(), runtimeDirs, emitted); } //---------------------------------------------------------------------------- diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 1826f42..204bd9a 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1867,6 +1867,9 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH", cmProperty::VARIABLE,0,0); + cm->DefineProperty( + "CMAKE_<LANG>_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH", + cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_SHARED_MODULE_CREATE_<LANG>_FLAGS", cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_SHARED_MODULE_<LANG>_FLAGS", |