@@ -79,29 +79,26 @@ macro(find_ablastr)
7979 set (WarpX_IPO ${ImpactX_IPO} CACHE INTERNAL "" FORCE )
8080
8181 # shared libs, i.e. for Python bindings, need relocatable code
82- # note: assign in both directions, otherwise re-configuring an existing
83- # build directory with ImpactX_PYTHON=OFF keeps the stale ON
8482 if (ImpactX_PYTHON OR BUILD_SHARED_LIBS )
85- set (AMReX_PIC ON CACHE INTERNAL
86- "Build AMReX with position independent code" )
87- set (ABLASTR_POSITION_INDEPENDENT_CODE ON CACHE INTERNAL
88- "Build ABLASTR with position independent code" )
83+ # Normal variables apply these requirements without overwriting
84+ # caller-owned cache entries when the requirements later disappear.
85+ set (AMReX_PIC ON )
86+ set (ABLASTR_POSITION_INDEPENDENT_CODE ON )
8987
9088 # WE NEED AMReX AS SHARED LIB, OTHERWISE WE CANNOT SHARE ITS GLOBALS
9189 # BETWEEN MULTIPLE PYTHON MODULES
9290 # TODO this is likely an export/symbol hiding issue that we could
9391 # alleviate later on
94- set (AMReX_BUILD_SHARED_LIBS ON CACHE BOOL "Build AMReX shared library" FORCE )
92+ set (AMReX_BUILD_SHARED_LIBS ON )
9593 else ()
96- set (AMReX_PIC OFF CACHE INTERNAL
97- "Build AMReX with position independent code" )
98- set (ABLASTR_POSITION_INDEPENDENT_CODE OFF CACHE INTERNAL
99- "Build ABLASTR with position independent code" )
100-
101- # unset rather than OFF: ABLASTR derives AMReX_INSTALL from whether
102- # anybody forced this, so restore the "nobody did" state
103- if (DEFINED AMReX_BUILD_SHARED_LIBS)
104- unset (AMReX_BUILD_SHARED_LIBS CACHE )
94+ # Use normal variables as re-evaluated defaults. With CMP0077 NEW,
95+ # downstream option() calls honor them without creating stale cache
96+ # entries, while explicit caller values win.
97+ if (NOT DEFINED AMReX_PIC)
98+ set (AMReX_PIC OFF )
99+ endif ()
100+ if (NOT DEFINED ABLASTR_POSITION_INDEPENDENT_CODE)
101+ set (ABLASTR_POSITION_INDEPENDENT_CODE OFF )
105102 endif ()
106103 endif ()
107104
0 commit comments