ENH: Added target property INSTALL_RPATH_USE_LINK_PATH to append the linker search path directories not inside the project to the INSTALL_RPATH automatically. The property is initialized by the variable CMAKE_INSTALL_RPATH_USE_LINK_PATH when the target is created.
This commit is contained in:
parent
60487a227e
commit
b4542762a7
|
@ -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 += " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 "
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue