Skip to content

Modernise build/refind of VecGeom and Geant4 Externals

This is a follow up to discussion in !1001. The changes trialled there to build an External for the Celeritas project highlighted a maintenance task to clean up the VecGeom and Geant4 builds/installs, and to use the supplied CMake support files for find_package to find the latter, independent of the aim to build Celeritas. For example, integration of the G4HepEM package also requires these changes.

This MR attempts to complete this task by largely copying the non-CUDA/Celeritas related changes by @akraszna in !1001:

  • Enable GDML support in VecGeom
  • Don't build VecGeom tests
  • Allow Geant4 to be refound multiple times without error (refinding of VecGeom dependency)
  • Install the Geant4Config.cmake et al files, only removing the obsolete Linux-g++ symlink

and updating the Geant4 build and FindGeant4.cmake module to:

  • not install the Geant4PackageCache.cmake file so that Geant4 relies on CMAKE_PREFIX_PATH and similar CMake standard variables to refind dependencies without hardcoding paths
  • implement FindGeant4.cmake as a wrapper around find_package(Geant4 NO_MODULE) to locate Geant4 via Geant4Config.cmake et al.
    • Follow CMake documentation on pattern of use
    • Post process to remove include_directories setting by Geant4Config.cmake which is an artifact of supporting ROOT dictionary generation in example (original credit for this fix to @seth!)
    • Translate Geant4_ prefixed variables to GEANT4_ prefixed versions used/expected by ATLAS code (only Athena considered though)
    • Retain parsing of G4Version.hh to pick up ATLAS-patched version of G4VERSION_TAG
    • Remove all obsolete environment variables from GEANT4_ENVIRONMENT except for those needed to locate the Geant4 data libraries

The changes as tested on an aibuild machine result in successful builds of the externals themselves for AthSimulation and Athena projects, as well as using these to build Athena itself. The builds of Athena (Athena/AthSimulation) appear successful and result in at least a runnable Sim_tf.py.

I think it should therefore be reasonably complete, modulo review comments and any problems highlighted by broader CI testing.

Merge request reports