Skip to content

Modernisation of CMake scripting to simplify build of FullSimLight

Benjamin Morgan requested to merge bmorgan/GeoModel:modernize-cmake-fsl into master

With Athena now using Geant4 static/big libraries, optimization work has shifted to look at use of LTO/PGO. As these are relatively involved tasks, a first step is to use FullSimLight as a proof-of-principle for the flags and operations needed to support this. Though this work won't (at least at this stage) be integrated into GeoModel/FullSimLight, the need to hack at the build scripts has highlighted some modernizations/simplifications that can be made independently right now. These are not only useful to assist the LTO/PGO work, but for general efficiency and clarity of the build.

  • Bump CMake minimum to 3.16, tested up to 3.26. Could be reduced a little, but 3.16 or higher is now pretty common across all platforms (see Repology listing).
    • Allows removal of some workarounds needed with older versions
    • If FullSimLight also gets used to test use of Celeritas/AdePT GPU simulation libraries for ATLAS, a more modern CMake will be needed for better CUDA support.
  • Consistently create namespaces ALIAS targets in subprojects. Only link to namespaced GeoModel targets in subprojects
    • Avoids need to check whether a project is built in a full GeoModel build or standalone.
  • Make ExternalProject targets for JSON, Eigen, and Xerces-C dependencies of the internal imported targets
    • Avoids need to use add_dependencies on GeoModel targets that link to these. They simply link to the namespaced imported target, e.g. nlohmann_json::nlohmann_json and don't need to worry if this is coming from the builtin on the system.
  • Fully implement the FullSimLight target as an INTERFACE target so plugins just need to link to it.
  • Build the core of the FullSimLight application as an OBJECT library.
    • Applications just link to this instead of recompiling the sources each time for their own use.
  • General simplifications:
    • Keep all build commands for a target as close together as possible for clarity
    • Check subproject status using CMAKE_CURRENT_SOURCE_DIR instead of an artificial project command.
    • Remove dead code or no longer required/supported modules (e.g. Geant4_USE_FILE)

These have been tested locally on macOS with as many combinations of build options as I can enable and appears fine. CI is more than likely to highlight issues, but let's see what it throws up.

Merge request reports