CMake: keep derived AMReX options in sync on re-configure - #1637
Open
ax3l wants to merge 1 commit into
Open
Conversation
ax3l
force-pushed
the
cmake-cache-staleness
branch
from
September 5, 2026 05:31
d96cde1 to
196dc6f
Compare
`AMReX_PIC`, `ABLASTR_POSITION_INDEPENDENT_CODE` and `AMReX_BUILD_SHARED_LIBS` were written to the cache from the "on" branch of `if(ImpactX_PYTHON OR BUILD_SHARED_LIBS)`. Those entries outlive the requirement that created them, so re-configuring an existing build directory with `-DImpactX_PYTHON=OFF` kept the cached `ON` and produced a build that differs from a fresh configure of the same command line: AMReX stayed a shared library with no Python bindings asking for it. Set them as normal variables instead. With `CMP0077` `NEW`, which we already request for the ABLASTR superbuild, the `option()` calls downstream honor a normal variable and skip creating the cache entry, so the requirement applies for exactly the configure that asks for it and leaves nothing behind for the next one. Explicit `-D` values from the caller still take precedence, because they are cache entries and we no longer `FORCE` over them. No `else()` branch: with nothing cached there is nothing to reset, and assigning `OFF` there would override ABLASTR's own `ABLASTR_POSITION_INDEPENDENT_CODE` default of `ON` and change what a fresh non-Python configure builds today. Verified by configuring `ImpactX_PYTHON=ON`, re-configuring the same directory with `ImpactX_PYTHON=OFF`, and comparing against a fresh `ImpactX_PYTHON=OFF` configure. The effective values and the resulting `amrex_3d`/`ablastr_3d` target type and `POSITION_INDEPENDENT_CODE` now match the fresh configure exactly, and both match what `development` produces for a fresh configure. Same class of issue as BLAST-WarpX/warpx#7204 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pg2X154siq9ZHxZqosufjp
ax3l
force-pushed
the
cmake-cache-staleness
branch
from
September 5, 2026 05:32
196dc6f to
ba84b39
Compare
1 task
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.
AMReX_PIC,ABLASTR_POSITION_INDEPENDENT_CODEandAMReX_BUILD_SHARED_LIBSwere written to the cache from the "on" branch ofif(ImpactX_PYTHON OR BUILD_SHARED_LIBS). Those entries outlive the requirement that created them, so re-configuring an existing build directory with-DImpactX_PYTHON=OFFsilently kept the cachedONand left AMReX a shared library with no Python bindings asking for it.Set them as normal variables instead. With
CMP0077 NEW— which we already request for the ABLASTR superbuild — the downstreamoption()calls honor a normal variable and skip creating the cache entry, so the requirement applies for exactly the configure that asks for it and leaves nothing behind for the next one. Explicit-Dvalues from the caller still take precedence, because they are cache entries and we no longerFORCEover them.Details
There is deliberately no
else()branch. With nothing cached there is nothing to reset, and assigningOFFthere would override ABLASTR's ownABLASTR_POSITION_INDEPENDENT_CODEdefault ofONand change what a fresh non-Python configure builds today.AMReX_INSTALLkeeps working: ABLASTR derives it fromif(DEFINED AMReX_BUILD_SHARED_LIBS), andDEFINEDis true for a normal variable, so the Python configure still getsAMReX_INSTALL=ONandinstall(EXPORT "pyAMReXTargets" ...)is generated.Testing
Configured
ImpactX_PYTHON=ON, re-configured the same directory withImpactX_PYTHON=OFF, and compared against a freshImpactX_PYTHON=OFFconfigure. Probed the effective variable values plus the resultingamrex_3d/ablastr_3dtargetTYPEandPOSITION_INDEPENDENT_CODE, since the fix intentionally keeps these values out of the cache.PYTHON=OFFON→ re-configureOFFdevelopmentAMReX_PIC=ON, amrexSTATICAMReX_PIC=ON, amrexSHAREDAMReX_PIC=ON, amrexSTATICAMReX_PIC=ON, amrexSTATICA re-configured build directory now matches a fresh one, and the fresh configure still matches what
developmentproduces. TheImpactX_PYTHON=ONconfigure is unchanged fromdevelopmentas well: amrexSHARED+ PIC, ablastrSTATIC+ PIC,AMReX_INSTALL=ON.Same class of issue as BLAST-WarpX/warpx#7204 on the WarpX side.