fix(mcconfigurator): Fix to run without TGeant3
The MCConfigurator required TGeant3 and TGeant4 to run. Added compiler flags to enable running without any given transport engine.
Fixes issue #1620.
Checklist:
- [x] Followed the Contributing Guidelines
📝 Walkthrough
Walkthrough
The PR refactors mcconfigurator's build dependencies and optional feature support. It decouples mcconfigurator from hard-coded Geant3/Geant4/FastSim requirements by making these dependencies optional and detectable at compile-time via preprocessor macros. mcconfigurator now builds with only yaml-cpp present, while Geant3/Geant4/FastSim support is conditionally compiled when available.
Changes
| Cohort / File(s) | Summary |
|---|---|
Build configuration—dependency loosening fairroot/CMakeLists.txt |
Changed mcconfigurator add_subdirectory condition from (Geant3_FOUND AND Geant4VMC_FOUND AND yaml-cpp_FOUND AND TARGET FairRoot::FastSim) to (yaml-cpp_FOUND), decoupling from Geant/FastSim hard requirements. |
Build configuration—feature flags and linkage fairroot/mcconfigurator/CMakeLists.txt |
Added public compile definitions (FAIRROOT_HAS_GEANT3, FAIRROOT_HAS_GEANT4, FAIRROOT_HAS_FASTSIM) when respective components are found; converted private linkage of geant321, geant4vmc, and FairRoot::FastSim to conditional public linkage; added EXTRA_INCLUDE_DIRS to ROOT dictionary target; updated copyright year. |
CMake reorganization examples/CMakeLists.txt |
Updated copyright year (2014-2022 → 2014-2025); moved add_subdirectory(common/gconfig) from inside Geant3_FOUND conditional to unconditional pre-check (gated on MCConfigurator). |
Conditional compilation implementation fairroot/mcconfigurator/FairYamlVMCConfig.cxx |
Replaced unconditional includes of FairFastSimRunConfiguration.h, TGeant3.h, TGeant3TGeo.h, and TGeant4.h with #ifdef-guarded includes (FAIRROOT_HAS_*); wrapped SetupPostInit(), SetupGeant3(), and SetupGeant4() implementations with feature guards; added fatal error messages when required features are unavailable; refactored Geant4 setup to conditionally build FastSim TG4RunConfiguration. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20–25 minutes
- fairroot/CMakeLists.txt: Verify that loosening the mcconfigurator condition from four requirements to one does not break supported build scenarios; ensure this aligns with downstream consumers.
- fairroot/mcconfigurator/CMakeLists.txt: Confirm all three conditional PUBLIC link targets and their guards are correctly paired with the new compile definitions.
-
FairYamlVMCConfig.cxx: Cross-check that all
#ifdefpreprocessor guards in the source file match the corresponding compile definition conditions in CMakeLists.txt; verify fatal error messages are user-friendly and direct users to rebuild with required support. - Integration: Ensure the interplay between loosened build conditions and conditional compilation guards allows graceful degradation when optional components are absent.
Possibly related PRs
-
FairRootGroup/FairRoot#1611: Directly related—both PRs modify
fairroot/CMakeLists.txtto decouple component inclusion from hard Geant3 requirements by moving or conditional-checking the mcconfigurator addition.
Suggested reviewers
- ChristianTackeGSI
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately summarizes the main change: adding support for running MCConfigurator without TGeant3, which is the core focus of the changeset. |
| Description check | ✅ Passed | The description is directly related to the changeset, explaining that compiler flags were added to enable running without transport engines and referencing the corresponding issue. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.