[CMake] Support builds with CMAKE_BUILD_WITH_INSTALL_RPATH=ON and gnuinstall=ON#19766
Conversation
Test Results 21 files 21 suites 3d 22h 12m 55s ⏱️ For more details on these failures, see this check. Results for commit 3183c29. ♻️ This comment has been updated with latest results. |
|
So on Windows, the DLLs are found in the PATH env variable, like any other executable. |
7b4d9aa to
e603699
Compare
LD_LIBRARY_PATH on Windows for rootclingTO_NATIVE_PATH_LIST to build rootcling invocations
a63d46e to
a0f5da1
Compare
TO_NATIVE_PATH_LIST to build rootcling invocationsrootcling RPATH for build tree includes library dir
rootcling RPATH for build tree includes library dir34f7acd to
97a6cf2
Compare
This follows up on e0f8cbc, implementing a more elegant solution for the problem in root-project#19327, which is now better understood. The problem was the interaction between my commit c77bd87 in the 6.36 development cycle, the `CMAKE_BUILD_WITH_INSTALL_RPATH=TRUE` option that is set by the MacPorts build system, and the `gnuinstall=ON` option. In case of `gnuinstall=ON`, the install tree directories are different form the build tree directories, in particular the relative path from the binary to the library directory. The correct RPATH values are inferred from this relative path. Now, when the user sets `CMAKE_BUILD_WITH_INSTALL_RPATH=TRUE` at configuration time, CMake uses the RPATHs for the install tree also for the build tree, which is not correct. The build of ROOT will fail, because `rootcling` doesn't have the right RPATH, and `rootcling` is used during the build. Two mechanisms in the ROOT CMake code were in place to guard against this problem. 1. The `LD_LIBRARY_PATH` is set in the `rootcling` calls during the build, on Linux the build would have succeeded. But on macOS, is was forgotten to use `DYLD_LIBRARY_PATH`, which was not done correctly until recently with e0f8cbc. 2. Another way how ROOT worked around this RPATH consistenty problem was to simply set `CMAKE_BUILD_WITH_INSTALL_RPATH=FALSE`, no matter what the user wants. I thought overriding these global `CMAKE_*` parameters that are quite useful for the users is not good practice, so I removed that in c77bd87. So mechanism 1 failed because of macOS, and mechanism 2 failed because I removed it. Now that I understood the real problem, this commit implements the proper solution: override the global `CMAKE_BUILD_WITH_INSTALL_RPATH` only for the `rootcling` target, so that it can be used during the build successfully. This means we can also remove the mechanism 1 that set the library path for `rootcling` during the build, as the RPATH is now guaranteed to be correct. Removing that mechanism makes the CMake code more homogeneus with the Windows version, since setting the library path on Windows is not necessary.
97a6cf2 to
940c28f
Compare
CMAKE_BUILD_WITH_INSTALL_RPATH=ON and gnuinstall=ON
Like this, we don't have to hack the RPATH when relocating the XRootD install to the ROOT install.
e3032c2 to
a3932b9
Compare
This reverts root-project/roottest@f34c844 from 2017. I don't see any problem when running the tests with ninja, and now we also have a ninja build in the CI to check it. This greatly speeds up running `roottest` when using ninja.
a3932b9 to
3183c29
Compare
|
The third commit ("[CMake] Never force |
This follows up on guitargeek@e0f8cbc, implementing a more elegant solution
for the problem in #19327, which is now better understood.
The problem was the interaction between my commit guitargeek@c77bd87 in the
6.36 development cycle, the
CMAKE_BUILD_WITH_INSTALL_RPATH=TRUEoption thatis set by the MacPorts build system, and the
gnuinstall=ONoption.In case of
gnuinstall=ON, the install tree directories are differentform the build tree directories, in particular the relative path from
the binary to the library directory. The correct RPATH values are
inferred from this relative path. Now, when the user sets
CMAKE_BUILD_WITH_INSTALL_RPATH=TRUEat configuration time, CMake usesthe RPATHs for the install tree also for the build tree, which is not
correct. The build of ROOT will fail, because
rootclingdoesn't havethe right RPATH, and
rootclingis used during the build.Two mechanisms in the ROOT CMake code were in place to guard against
this problem.
The
LD_LIBRARY_PATHis set in therootclingcalls during thebuild, on Linux the build would have succeeded. But on macOS, is was
forgotten to use
DYLD_LIBRARY_PATH, which was not done correctlyuntil recently with guitargeek@e0f8cbc.
Another way how ROOT worked around this RPATH consistenty problem was to
simply set
CMAKE_BUILD_WITH_INSTALL_RPATH=FALSE, no matter what theuser wants. I thought overriding these global
CMAKE_*parameters thatare quite useful for the users is not good practice, so I removed that
in guitargeek@c77bd87.
So mechanism 1 failed because of macOS, and mechanism 2 failed because I
removed it.
Now that I understood the real problem, this commit implements the
proper solution: override the global
CMAKE_BUILD_WITH_INSTALL_RPATHonly for the
rootclingtarget, so that it can be used during the buildsuccessfully.
This means we can also remove the mechanism 1 that set the library path
for
rootclingduring the build, as the RPATH is now guaranteed to becorrect. Removing that mechanism makes the CMake code more homogeneus
with the Windows version, since setting the library path on Windows is
not necessary.