Skip to content

Simplify usage of preprocessor flags in VecGeom

Benjamin Morgan requested to merge bmorgan/simplify-preprocessor-use into master

VecGeom enables/disables features in its API and ABI via preprocessor conditionals, e.g. #ifdef VECGEOM_SCALAR. The definition of these symbols is done by appending -D flags to a CMake variable, and then to CMAKE_CXX_FLAGS. Additionally, this VECGEOM_DEFINITIONS variable is exported to VecGeomConfig.cmake, and applied globally to any including project with add_definitions.

This is suboptimal as the set of flags used to build the VecGeom library fix its API and ABI, requiring any client to use exactly the same set of -D flags. Whilst VecGeomConfig uses add_definitions, client projects are at liberty to change the build settings, and clients may not use CMake at all. Though they could be provided through a pkg-config file in the latter case, the fundamental awkwardness of transporting easily modifiable flags that strictly fix the API/ABI remains.

This MR implements a Config.h header for VecGeom, configured at CMake time with #define/undef directives for VecGeom's symbols as configured at build time. These are set via the CMake options for them, and the header included in the Global.h header. This inclusion is a first pass as most VecGeom headers and sources should include this, but testing is likely to reveal issues (hence the WIP).

Config.h also needs documentation for the symbols - would using the same description as their corresponding options in CMake into equivalent Doxygen lines be sufficient?

Edited by Benjamin Morgan

Merge request reports