[CMake] Set rpath for individual targets and not globally#19501
Merged
Conversation
hageboeck
reviewed
Aug 1, 2025
5417d48 to
fa6f67f
Compare
fa6f67f to
88740e0
Compare
Test Results 19 files 19 suites 3d 4h 23m 44s ⏱️ Results for commit 7af2b1d. ♻️ This comment has been updated with latest results. |
88740e0 to
2342063
Compare
hageboeck
approved these changes
Aug 4, 2025
Member
hageboeck
left a comment
There was a problem hiding this comment.
LGTM, but I added a few more suggestions.
When using the `rpath=ON` option, the global CMake variable `CMAKE_INSTALL_RPATH` is mutated, which is problematic in several corner cases. This commit suggests to append the rpaths at the target property level, and also set the rpaths for the build tree separately so they make sense. A new ROOT macro is introduced for this rpath setting, which are also used for the PyROOT libraries, which also need custom rpaths. Closes root-project#19327 and root-project#19134.
Since ROOT 6.36, the relative `RPATH` to the main ROOT libraries is only appended to the existing path, and not replacing the path that is e.g. passed by the user via `CMAKE_INSTALL_RPATH`. Therefore, there is no problematic side effect of `rpath=ON` anymore. We can drop this option and always append to the runpath. This makes the ROOT configuration less confusing, also because from the option name "rpath", it is not clear what it did.
2342063 to
7af2b1d
Compare
This was referenced Aug 4, 2025
Member
|
I think this PR results in a breaking change that |
guitargeek
added a commit
to guitargeek/root
that referenced
this pull request
Sep 23, 2025
Follows up on 26d24de, where the `rpath` configuration path was made the default and can't be disabled anymore. This means that the `rpath` CMake configuration option is gone, but there was still some code that checked it, which I missed to update. Addresses root-project#19501 (comment).
guitargeek
added a commit
that referenced
this pull request
Sep 23, 2025
Follows up on 26d24de, where the `rpath` configuration path was made the default and can't be disabled anymore. This means that the `rpath` CMake configuration option is gone, but there was still some code that checked it, which I missed to update. Addresses #19501 (comment).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When using the
rpath=ONoption, the global CMake variableCMAKE_INSTALL_RPATHis mutated, which is problematic in several corner cases.Furthermore, the path is set to match the install tree, resulting in nonsensical relative rpath for the build tree if the directory structure is different (e.g. because of
gnuinstall=ON).This commit suggests to append the rpaths at the target property level, and also set the rpaths for the build tree separately so they make sense.
New ROOT macros are introduced for this rpath setting, which are also used for the PyROOT libraries, which also need custom rpaths.
Closes #19327 and #19134.
Here are some rpaths for relevant libraries and executables with
gnuinstall=ONandrpath=ON, before and after this PR: