diff options
-rw-r--r-- | Source/cmLocalGenerator.cxx | 25 | ||||
-rw-r--r-- | Source/cmSetTargetPropertiesCommand.h | 6 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
3 files changed, 28 insertions, 4 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 52f48ac..a73fbce 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1418,6 +1418,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, outputRuntime && tgt.HaveInstallTreeRPATH() && linking_for_install; bool use_build_rpath = outputRuntime && tgt.HaveBuildTreeRPATH() && !linking_for_install; + bool use_link_rpath = + outputRuntime && linking_for_install && + tgt.GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::vector<std::string> runtimeDirs; @@ -1454,13 +1457,29 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, && libDir->find("${") == std::string::npos) { linkLibs += libPathFlag; + linkLibs += fullLibPath; + linkLibs += " "; + + // Put this directory in the rpath if using build-tree rpath + // support or if using the link path as an rpath. if(use_build_rpath) { - runtimeDirs.push_back( fullLibPath ); + runtimeDirs.push_back(fullLibPath); + } + else if(use_link_rpath) + { + // Do not add any path inside the source or build tree. + const char* topSourceDir = this->Makefile->GetHomeDirectory(); + const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory(); + if(!cmSystemTools::ComparePath(libDir->c_str(), topSourceDir) && + !cmSystemTools::ComparePath(libDir->c_str(), topBinaryDir) && + !cmSystemTools::IsSubDirectory(libDir->c_str(), topSourceDir) && + !cmSystemTools::IsSubDirectory(libDir->c_str(), topBinaryDir)) + { + runtimeDirs.push_back(fullLibPath); + } } } - linkLibs += fullLibPath; - linkLibs += " "; } } diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 9bd3483..7de65c1 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -112,6 +112,9 @@ public: "There are a few properties used to specify RPATH rules. " "INSTALL_RPATH is a semicolon-separated list specifying the rpath " "to use in installed targets (for platforms that support it). " + "INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true will " + "append directories in the linker search path and outside the project " + "to the INSTALL_RPATH. " "SKIP_BUILD_RPATH is a boolean specifying whether to skip automatic " "generation of an rpath allowing the target to run from the " "build tree. " @@ -122,7 +125,8 @@ public: "directory portion of the \"install_name\" field of shared libraries " "on Mac OSX to use in the installed targets. " "When the target is created the values of " - "the variables CMAKE_INSTALL_RPATH, CMAKE_SKIP_BUILD_RPATH, " + "the variables CMAKE_INSTALL_RPATH, " + "CMAKE_INSTALL_RPATH_USE_LINK_PATH, CMAKE_SKIP_BUILD_RPATH, " "CMAKE_BUILD_WITH_INSTALL_RPATH, and CMAKE_INSTALL_NAME_DIR " "are used to initialize these properties.\n" "PROJECT_LABEL can be used to change the name of " diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5f0998a..26bc47d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -63,6 +63,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Setup default property values. this->SetPropertyDefault("INSTALL_NAME_DIR", ""); this->SetPropertyDefault("INSTALL_RPATH", ""); + this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); |