-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support use with linkers/setups needing rpath-link (#8)
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 1. The installed dependencies (here, Geant4, VecGeom) do not have their rpath set correctly. 2. They are otherwise in a location the linker is not aware of, e.g. via ldconfig of 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. Workaround 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.
- Loading branch information
1 parent
804ea9c
commit f372cdd
Showing
5 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
@PACKAGE_INIT@ | ||
|
||
# Refind dependencies in case linker needs paths to resolve | ||
include(CMakeFindDependencyMacro) | ||
find_dependency(Geant4) | ||
find_depencency(VecGeom) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/G4VGTargets.cmake") | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file G4VG.link.test.cc | ||
//---------------------------------------------------------------------------// | ||
|
||
#include "G4VG.hh" | ||
|
||
int main() {} |