Skip to content

Conversation

@karabowi
Copy link
Collaborator

@karabowi karabowi commented Dec 4, 2025

The MCConfigurator required TGeant3 and TGeant4 to run. Added compiler flags to enable running without any given transport engine.

Fixes issue #1620.


Checklist:

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

📝 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 #ifdef preprocessor 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

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
fairroot/mcconfigurator/FairYamlVMCConfig.cxx (1)

68-131: Potential unused parameter warning when Geant4 is disabled.

When FAIRROOT_HAS_GEANT4 is not defined, the mcEngine parameter is unused, which may trigger compiler warnings.

Apply this diff to suppress the warning:

 void FairYamlVMCConfig::SetupPostInit(const char* mcEngine)
 {
 #ifdef FAIRROOT_HAS_GEANT4
     if (!fPostInitFlag) {
 ...
 #else
+    (void)mcEngine;  // Suppress unused parameter warning
     LOG(fatal) << "FairYamlVMCConfig::SetupPostInit() - Geant4 support is not available! "
                << "FairRoot was compiled without Geant4. "
                << "Please use TGeant3 or recompile FairRoot with Geant4 support.";
 
 #endif
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e22c961 and e7f4d88.

📒 Files selected for processing (4)
  • examples/CMakeLists.txt (2 hunks)
  • fairroot/CMakeLists.txt (1 hunks)
  • fairroot/mcconfigurator/CMakeLists.txt (2 hunks)
  • fairroot/mcconfigurator/FairYamlVMCConfig.cxx (8 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-06-14T10:16:00.050Z
Learnt from: dennisklein
Repo: FairRootGroup/FairRoot PR: 1560
File: cmake/private/FairRootConfig.cmake.in:13-13
Timestamp: 2024-06-14T10:16:00.050Z
Learning: `PACKAGE_PROJECT_CMAKEMOD_DIR` is defined by the call to `configure_package_config_file()` in the CMake configuration process for FairRoot.

Applied to files:

  • fairroot/CMakeLists.txt
  • examples/CMakeLists.txt
  • fairroot/mcconfigurator/FairYamlVMCConfig.cxx
  • fairroot/mcconfigurator/CMakeLists.txt
🔇 Additional comments (7)
fairroot/mcconfigurator/FairYamlVMCConfig.cxx (3)

31-41: LGTM! Conditional includes are correctly structured.

The guarded includes properly isolate optional dependencies, preventing compilation errors when Geant3/Geant4/FastSim are not available.


133-181: LGTM!

The conditional compilation guard and fatal error message are correctly implemented, providing clear guidance when Geant3 support is unavailable.


244-249: LGTM!

The fallback fatal error message is consistent with the Geant3 pattern and provides clear guidance.

examples/CMakeLists.txt (1)

14-16: LGTM!

Moving the gconfig subdirectory inclusion outside the Geant3_FOUND block correctly reflects that MCConfigurator now only requires yaml-cpp to build.

fairroot/CMakeLists.txt (1)

43-45: LGTM!

Relaxing the condition to only require yaml-cpp_FOUND correctly enables building MCConfigurator without transport engines. The individual backend dependencies are now properly handled via compile definitions in mcconfigurator/CMakeLists.txt.

fairroot/mcconfigurator/CMakeLists.txt (2)

25-34: LGTM!

The compile definitions are correctly set based on the availability of each component, and PUBLIC visibility ensures consumers can also use these guards when including MCConfigurator headers.


56-61: LGTM!

The conditional linking of FairRoot::FastSim correctly requires both Geant4VMC_FOUND and the target existence.

The MCConfigurator required TGeant3 and TGeant4 to run.
Added compiler flags to enable running without any given transport engine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant