Skip to content

Support modern Garfield via GARFIELD_HOME (Component vs ComponentBase) - #131

Merged
cmargalejo merged 3 commits into
masterfrom
cris_garfield_modern_detection
Jul 24, 2026
Merged

Support modern Garfield via GARFIELD_HOME (Component vs ComponentBase)#131
cmargalejo merged 3 commits into
masterfrom
cris_garfield_modern_detection

Conversation

@cmargalejo

@cmargalejo cmargalejo commented Jun 29, 2026

Copy link
Copy Markdown
Member

cmargalejo Ok: 8 Powered by Pull Request Badge

Problem

When Garfield is found through the GARFIELD_HOME path, CMakeLists.txt defines -DUSE_Garfield_OLD unconditionally, which forces the legacy Garfield::ComponentBase API.

Recent Garfield versions renamed that class to Garfield::Component (and the header ComponentBase.hhComponent.hh). Building the detector library against such a Garfield through GARFIELD_HOME therefore fails:

fatal error: ComponentBase.hh: No such file or directory

Fix

Only define USE_Garfield_OLD when the legacy header is actually present:

if (EXISTS "${Garfield_INCLUDE_DIRS}/ComponentBase.hh")
    add_definitions(-DUSE_Garfield_OLD)
endif ()

The headers (TRestDetectorGeometry.h, TRestDetectorGarfieldDriftProcess.h) already select the correct API from this flag — ComponentBase under USE_Garfield_OLD, Component otherwise — so no source changes are needed. Old Garfield keeps working; recent Garfield now builds as well.

cmargalejo and others added 2 commits June 29, 2026 10:46
The GARFIELD_HOME detection path unconditionally defined USE_Garfield_OLD, which
forces the legacy Garfield::ComponentBase API. Modern Garfield renamed that class
to Garfield::Component (and ComponentBase.hh -> Component.hh), and is increasingly
reached through GARFIELD_HOME because LCG/CVMFS installs ship no Garfield CMake
config. Only enable the legacy path when ComponentBase.hh is actually present, so
both old and modern Garfield build. The headers already select the right API from
this flag, so no source changes are needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@Vindaar Vindaar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems fine to me.

@cmargalejo
cmargalejo merged commit ddf7fb6 into master Jul 24, 2026
56 checks passed
@cmargalejo
cmargalejo deleted the cris_garfield_modern_detection branch July 24, 2026 13:59
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.

2 participants