cmake: do not override cmake rpath defines #5271
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your changes
This removes overriding the values of
CMAKE_INSTALL_RPATH_USE_LINK_PATH
Some package managers (e.g. Spack package manager) set this toON
to get automatic rpaths to e.g.libmpi.so
andlibz.so
if they are in non-standard locations.CMAKE_SKIP_BUILD_RPATH
/CMAKE_BUILD_WITH_INSTALL_RPATH
: they're redundant, just use the defaults to follow the principle of least astonishment. If you ever run a just-built executable during the build, then leaving those to the standard value is better, since you don't really know where the executables/libraries reside during the build.CMAKE_INSTALL_NAME_DIR
: this was a workaround for CMake < 3 on macOS. As of CMake 3, it's the default, see CMP0042.CMAKE_INSTALL_RPATH
. Setting this variable overrides what the user passes through-DCMAKE_INSTALL_RPATH
. This PR results in$ORIGIN
and$ORIGIN/../lib
being dropped from install rpaths. These rpaths are not desirable on certain distros where the libs are installed in default search locations, and lookup in the ld.so cache is better. Currently, users cannot opt out of these rpaths. With this change, it's opt-in by passing-DCMAKE_INSTALL_RPATH=<install prefix>/lib
if they install to non-standard location, like they would already do for every other CMake project out there.** if this project really insists on $ORIGIN type rpaths for locating libraries in hdf5's own install prefix, then I would suggest to make it a target property instead or use
list(APPEND ...)
instead of overriding the user value.The reason for this changes is: the user knows better than the build system whether or not install rpaths are needed and what they should be. The build system does not know whether the install prefix is "non-standard" or if rpaths to dependencies are desirable. The rpath logic of HDF5 is opinionated, and has no opt-out, does not deal with dependencies like zlib / mpi / etc in non-standard directories, and is somewhat outdated w.r.t. macOS.
Issue ticket number (GitHub or JIRA)
Checklist before requesting a review