Support use with linkers/setups needing rpath-link #8
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.
Discovered in testing of integration of G4VG in apt-sim/AdePT#289, targets linking to installed G4VG may fail to link due to linker not having needed information on location of deps-of-deps of G4VG. This happens in build environments where
LD_LIBRARY_PATH
etc.The link error warns about this and suggests adding the path through, e.g.
-rpath-link
. CMake will always add this flag/path correctly, but only if it knows about the dependencies (even if private).The G4VG library only depends on the static
Celeritas::geocel
target, which does not forward its dependencies to Geant4/Vecgeom and so it does not set-rpath-link
for these in downstream usersWorkaround this issue by explicitly making used Geant4 targets
PRIVATE
deps of the g4vg target. Refind Geant4/VecGeom dependencies when finding G4VG so these are resolved and available if the linker requires it.Add smoke test for linking that simply tries to link only the G4VG target. Confirmed to reproduce problem observed in AdePT, with the fixes above resolving it.
Despite the above linked CMake post, this feels somewhat hacky/messy and am not 100% sure it's the right approach as
r/runpath
of the thing needing linking. It's not been spotted before due to the primary use of Spack, which setsr/runpaths
for each package and target(s) within those packages correctly.However, it does seem like
G4VG
needs to at least declare directly its Geant4/VecGeom deps so these populate theIMPORTED_LINK_DEPENDENT_LIBRARIES
property noted in the CMake Discourse discussion.