Support modern Garfield via GARFIELD_HOME (Component vs ComponentBase) - #131
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Garfield is found through the
GARFIELD_HOMEpath,CMakeLists.txtdefines-DUSE_Garfield_OLDunconditionally, which forces the legacyGarfield::ComponentBaseAPI.Recent Garfield versions renamed that class to
Garfield::Component(and the headerComponentBase.hh→Component.hh). Building the detector library against such a Garfield throughGARFIELD_HOMEtherefore fails:fatal error: ComponentBase.hh: No such file or directory
Fix
Only define
USE_Garfield_OLDwhen the legacy header is actually present: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.