From 091de977c7fd79998b4f3149662620e819d3fd39 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Sep 2026 17:28:57 -0400 Subject: [PATCH 1/7] cmake: forward TA_ASSERT_POLICY to BTAS built from source TA_ASSERT_POLICY was not forwarded to BTAS, so BTAS_ASSERT_THROWS fell back to its own default, BUILD_TESTING -- i.e. BTAS_ASSERT threw (regardless of NDEBUG) whenever TA's tests were built, even in configurations where TA_ASSERT aborts or is a no-op. FindOrFetchBTAS.cmake now sets BTAS_ASSERT_THROWS ON iff TA_ASSERT_POLICY is TA_ASSERT_THROW, OFF for TA_ASSERT_ABORT and TA_ASSERT_IGNORE (BTAS has no abort mode; with BTAS_ASSERT_THROWS=OFF BTAS_ASSERT is a plain assert(), the closest match for TA_ASSERT_ABORT). Guarded by NOT DEFINED, so a user -D or a parent project that sets BTAS_ASSERT_THROWS first keeps control. --- INSTALL.md | 2 +- cmake/modules/FindOrFetchBTAS.cmake | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 928eba7fa8..d122d07593 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -424,7 +424,7 @@ support may be added. ## Expert configure options: * `TA_EXPERT` -- Set to `ON` to disable automatic installation of prerequisites. Useful for experts, hence the name. [Default=OFF]. -* `TA_ASSERT_POLICY` -- Set to `TA_ASSERT_IGNORE` to disable `TA_ASSERT` assertions, `TA_ASSERT_THROW` to cause `TA_ASSERT` assertions to throw, `TA_ASSERT_ABORT` to cause `TA_ASSERT` assertions to abort. The default is `TA_ASSERT_IGNORE` if CMake uses a single-configuration generator and`CMAKE_BUILD_TYPE` is set to `Release` or `MinSizeRel`, else the default is `TA_ASSERT_THROW`. +* `TA_ASSERT_POLICY` -- Set to `TA_ASSERT_IGNORE` to disable `TA_ASSERT` assertions, `TA_ASSERT_THROW` to cause `TA_ASSERT` assertions to throw, `TA_ASSERT_ABORT` to cause `TA_ASSERT` assertions to abort. The default is `TA_ASSERT_IGNORE` if CMake uses a single-configuration generator and`CMAKE_BUILD_TYPE` is set to `Release` or `MinSizeRel`, else the default is `TA_ASSERT_THROW`. This is also forwarded to BTAS, as `BTAS_ASSERT_THROWS` (ON for `TA_ASSERT_THROW`, OFF otherwise), when BTAS is built from source; set `BTAS_ASSERT_THROWS` explicitly to override. * `BUILD_TESTING` -- Set of `OFF` to disable building unit tests. The default is `ON`. * `TA_TRACE_TASKS` -- Set to `ON` to enable tracing of MADNESS tasks using custom task tracer. Note that standard profilers/tracers are generally useless (except in the trivial cases) with MADWorld-based programs since the submission context of tasks is not captured by standard tracing tools; this makes it impossible in a nontrivial program to attribute tasks to source code. WARNING: task tracing his will greatly increase the memory requirements. [Default=OFF]. * `TA_TTG` -- Set to `ON` to find or fetch the TTG library. [Default=OFF]. diff --git a/cmake/modules/FindOrFetchBTAS.cmake b/cmake/modules/FindOrFetchBTAS.cmake index 9071c11158..08fd27f924 100644 --- a/cmake/modules/FindOrFetchBTAS.cmake +++ b/cmake/modules/FindOrFetchBTAS.cmake @@ -28,6 +28,22 @@ if (NOT TARGET BTAS::BTAS) set(gpu_backend none CACHE STRING "The device backend to use for Linalg++") endif() + # forward TA's assertion policy to BTAS, else BTAS defaults BTAS_ASSERT_THROWS + # to BUILD_TESTING, i.e. BTAS_ASSERT throws (regardless of NDEBUG) whenever + # tests are built, no matter what TA_ASSERT does. + # N.B. BTAS has no abort mode; with BTAS_ASSERT_THROWS=OFF BTAS_ASSERT is a + # plain assert(), which is the closest match for TA_ASSERT_ABORT (aborts + # in Debug, elided under NDEBUG) + # N.B. only if the user did not ask for a specific BTAS_ASSERT_THROWS, hence a + # parent project that sets BTAS_ASSERT_THROWS first keeps control + if (NOT DEFINED BTAS_ASSERT_THROWS) + if (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) + set(BTAS_ASSERT_THROWS ON CACHE BOOL "Whether BTAS_ASSERT should throw") + else () + set(BTAS_ASSERT_THROWS OFF CACHE BOOL "Whether BTAS_ASSERT should throw") + endif() + endif (NOT DEFINED BTAS_ASSERT_THROWS) + include(FetchContent) FetchContent_Declare( BTAS From daedd958965f75596fcdbfb3e751d5ed46019651 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Sep 2026 19:54:20 -0400 Subject: [PATCH 2/7] bump BTAS tag to 52aadfe54ee48874f6926da5932482e0f5cef85c (BTAS_ASSERT_POLICY) --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index f5565d299c..8b7920a100 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -17,8 +17,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG f7aa1401e) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 245e49f117981d6124e0f1aa0d1ae72f1c16318b) -set(TA_TRACKED_BTAS_PREVIOUS_TAG 7e64fbad97c76f316f313f4c8ed3fca5445da15f) +set(TA_TRACKED_BTAS_TAG 52aadfe54ee48874f6926da5932482e0f5cef85c) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 245e49f117981d6124e0f1aa0d1ae72f1c16318b) set(TA_TRACKED_LIBRETT_TAG 6eed30d4dd2a5aa58840fe895dcffd80be7fbece) set(TA_TRACKED_LIBRETT_PREVIOUS_TAG 354e0ccee54aeb2f191c3ce2c617ebf437e49d83) From b4dafc852e737d120165d2a8d9dd95a476b34a73 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Sep 2026 19:54:24 -0400 Subject: [PATCH 3/7] cmake: forward TA_ASSERT_POLICY to BTAS as BTAS_ASSERT_POLICY BTAS (ValeevGroup/BTAS#188) now has the same three assertion modes as TA; map TA_ASSERT_{THROW,ABORT,IGNORE} onto BTAS_ASSERT_{THROW,ABORT,IGNORE} instead of the deprecated boolean BTAS_ASSERT_THROWS, whose OFF setting was a plain assert() (elided under NDEBUG) rather than an abort. --- cmake/modules/FindOrFetchBTAS.cmake | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cmake/modules/FindOrFetchBTAS.cmake b/cmake/modules/FindOrFetchBTAS.cmake index 08fd27f924..9b7e02ba9f 100644 --- a/cmake/modules/FindOrFetchBTAS.cmake +++ b/cmake/modules/FindOrFetchBTAS.cmake @@ -28,21 +28,21 @@ if (NOT TARGET BTAS::BTAS) set(gpu_backend none CACHE STRING "The device backend to use for Linalg++") endif() - # forward TA's assertion policy to BTAS, else BTAS defaults BTAS_ASSERT_THROWS - # to BUILD_TESTING, i.e. BTAS_ASSERT throws (regardless of NDEBUG) whenever - # tests are built, no matter what TA_ASSERT does. - # N.B. BTAS has no abort mode; with BTAS_ASSERT_THROWS=OFF BTAS_ASSERT is a - # plain assert(), which is the closest match for TA_ASSERT_ABORT (aborts - # in Debug, elided under NDEBUG) - # N.B. only if the user did not ask for a specific BTAS_ASSERT_THROWS, hence a - # parent project that sets BTAS_ASSERT_THROWS first keeps control - if (NOT DEFINED BTAS_ASSERT_THROWS) + # forward TA's assertion policy to BTAS, else BTAS picks its own default + # (BTAS_ASSERT_THROW whenever BUILD_TESTING=ON, no matter what TA_ASSERT does). + # BTAS_ASSERT_POLICY has the same three modes as TA_ASSERT_POLICY, and + # like it is not affected by NDEBUG. + # N.B. only if the user did not ask for a specific BTAS_ASSERT_POLICY, hence a + # parent project that sets BTAS_ASSERT_POLICY first keeps control + if (NOT DEFINED BTAS_ASSERT_POLICY) if (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) - set(BTAS_ASSERT_THROWS ON CACHE BOOL "Whether BTAS_ASSERT should throw") + set(BTAS_ASSERT_POLICY BTAS_ASSERT_THROW CACHE STRING "Controls the behavior of BTAS_ASSERT") + elseif (TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT) + set(BTAS_ASSERT_POLICY BTAS_ASSERT_ABORT CACHE STRING "Controls the behavior of BTAS_ASSERT") else () - set(BTAS_ASSERT_THROWS OFF CACHE BOOL "Whether BTAS_ASSERT should throw") + set(BTAS_ASSERT_POLICY BTAS_ASSERT_IGNORE CACHE STRING "Controls the behavior of BTAS_ASSERT") endif() - endif (NOT DEFINED BTAS_ASSERT_THROWS) + endif (NOT DEFINED BTAS_ASSERT_POLICY) include(FetchContent) FetchContent_Declare( From c4648f4b97af72e0572a319d157b5e0283a73247 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Sep 2026 19:54:40 -0400 Subject: [PATCH 4/7] INSTALL.md: TA_ASSERT_POLICY is forwarded to BTAS as BTAS_ASSERT_POLICY --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index d122d07593..451584fb87 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -424,7 +424,7 @@ support may be added. ## Expert configure options: * `TA_EXPERT` -- Set to `ON` to disable automatic installation of prerequisites. Useful for experts, hence the name. [Default=OFF]. -* `TA_ASSERT_POLICY` -- Set to `TA_ASSERT_IGNORE` to disable `TA_ASSERT` assertions, `TA_ASSERT_THROW` to cause `TA_ASSERT` assertions to throw, `TA_ASSERT_ABORT` to cause `TA_ASSERT` assertions to abort. The default is `TA_ASSERT_IGNORE` if CMake uses a single-configuration generator and`CMAKE_BUILD_TYPE` is set to `Release` or `MinSizeRel`, else the default is `TA_ASSERT_THROW`. This is also forwarded to BTAS, as `BTAS_ASSERT_THROWS` (ON for `TA_ASSERT_THROW`, OFF otherwise), when BTAS is built from source; set `BTAS_ASSERT_THROWS` explicitly to override. +* `TA_ASSERT_POLICY` -- Set to `TA_ASSERT_IGNORE` to disable `TA_ASSERT` assertions, `TA_ASSERT_THROW` to cause `TA_ASSERT` assertions to throw, `TA_ASSERT_ABORT` to cause `TA_ASSERT` assertions to abort. The default is `TA_ASSERT_IGNORE` if CMake uses a single-configuration generator and`CMAKE_BUILD_TYPE` is set to `Release` or `MinSizeRel`, else the default is `TA_ASSERT_THROW`. This is also forwarded to BTAS, as `BTAS_ASSERT_POLICY` (`TA_ASSERT_THROW`/`TA_ASSERT_ABORT`/`TA_ASSERT_IGNORE` map onto `BTAS_ASSERT_THROW`/`BTAS_ASSERT_ABORT`/`BTAS_ASSERT_IGNORE`), when BTAS is built from source; set `BTAS_ASSERT_POLICY` explicitly to override. * `BUILD_TESTING` -- Set of `OFF` to disable building unit tests. The default is `ON`. * `TA_TRACE_TASKS` -- Set to `ON` to enable tracing of MADNESS tasks using custom task tracer. Note that standard profilers/tracers are generally useless (except in the trivial cases) with MADWorld-based programs since the submission context of tasks is not captured by standard tracing tools; this makes it impossible in a nontrivial program to attribute tasks to source code. WARNING: task tracing his will greatly increase the memory requirements. [Default=OFF]. * `TA_TTG` -- Set to `ON` to find or fetch the TTG library. [Default=OFF]. From d112688f40bc4e3ccee9fb0a8933b61996de813c Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Sep 2026 20:12:59 -0400 Subject: [PATCH 5/7] cmake: re-derive BTAS_ASSERT_POLICY on reconfigure unless the user set it The derived value is a cache entry, so on the second configure the NOT DEFINED guard was false and a changed TA_ASSERT_POLICY left BTAS at the old policy. Record the derived value (TA_BTAS_ASSERT_POLICY_DERIVED, INTERNAL) and re-derive whenever BTAS_ASSERT_POLICY still equals it; an explicit user value survives reconfigures. --- cmake/modules/FindOrFetchBTAS.cmake | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/cmake/modules/FindOrFetchBTAS.cmake b/cmake/modules/FindOrFetchBTAS.cmake index 9b7e02ba9f..59298e4603 100644 --- a/cmake/modules/FindOrFetchBTAS.cmake +++ b/cmake/modules/FindOrFetchBTAS.cmake @@ -33,16 +33,23 @@ if (NOT TARGET BTAS::BTAS) # BTAS_ASSERT_POLICY has the same three modes as TA_ASSERT_POLICY, and # like it is not affected by NDEBUG. # N.B. only if the user did not ask for a specific BTAS_ASSERT_POLICY, hence a - # parent project that sets BTAS_ASSERT_POLICY first keeps control - if (NOT DEFINED BTAS_ASSERT_POLICY) - if (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) - set(BTAS_ASSERT_POLICY BTAS_ASSERT_THROW CACHE STRING "Controls the behavior of BTAS_ASSERT") - elseif (TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT) - set(BTAS_ASSERT_POLICY BTAS_ASSERT_ABORT CACHE STRING "Controls the behavior of BTAS_ASSERT") - else () - set(BTAS_ASSERT_POLICY BTAS_ASSERT_IGNORE CACHE STRING "Controls the behavior of BTAS_ASSERT") - endif() - endif (NOT DEFINED BTAS_ASSERT_POLICY) + # parent project that sets BTAS_ASSERT_POLICY first keeps control; + # a value that this module derived on an earlier configure (recorded in + # TA_BTAS_ASSERT_POLICY_DERIVED) is re-derived, so that reconfiguring + # with a different TA_ASSERT_POLICY keeps BTAS in sync + if (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) + set(_ta_btas_assert_policy BTAS_ASSERT_THROW) + elseif (TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT) + set(_ta_btas_assert_policy BTAS_ASSERT_ABORT) + else () + set(_ta_btas_assert_policy BTAS_ASSERT_IGNORE) + endif() + if (NOT DEFINED BTAS_ASSERT_POLICY OR + (DEFINED TA_BTAS_ASSERT_POLICY_DERIVED AND BTAS_ASSERT_POLICY STREQUAL TA_BTAS_ASSERT_POLICY_DERIVED)) + set(BTAS_ASSERT_POLICY ${_ta_btas_assert_policy} CACHE STRING "Controls the behavior of BTAS_ASSERT" FORCE) + set(TA_BTAS_ASSERT_POLICY_DERIVED ${_ta_btas_assert_policy} CACHE INTERNAL "BTAS_ASSERT_POLICY derived from TA_ASSERT_POLICY by TiledArray") + endif() + unset(_ta_btas_assert_policy) include(FetchContent) FetchContent_Declare( From 75abed2601c41a696341fc0d064dd02f0d18b32c Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Sep 2026 20:42:47 -0400 Subject: [PATCH 6/7] cmake: TA_BTAS_ASSERT_POLICY_FOLLOWS_TA is the unambiguous opt-out of BTAS policy forwarding CMake cannot distinguish an explicit -DBTAS_ASSERT_POLICY= from a cache entry that already holds , so matching the value against the last derived one could clobber an explicit override. Now: while TA_BTAS_ASSERT_POLICY_FOLLOWS_TA (default ON) is on, BTAS_ASSERT_POLICY is re-derived from TA_ASSERT_POLICY on every configure; an explicit value that differs from the one TA last acknowledged (TA_BTAS_ASSERT_POLICY_SEEN, INTERNAL) is honored and turns the option OFF; passing the option OFF explicitly is the unambiguous way to pin any value, and turning it back ON resumes following. --- INSTALL.md | 2 +- cmake/modules/FindOrFetchBTAS.cmake | 43 ++++++++++++++++++----------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 451584fb87..edadd009d9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -424,7 +424,7 @@ support may be added. ## Expert configure options: * `TA_EXPERT` -- Set to `ON` to disable automatic installation of prerequisites. Useful for experts, hence the name. [Default=OFF]. -* `TA_ASSERT_POLICY` -- Set to `TA_ASSERT_IGNORE` to disable `TA_ASSERT` assertions, `TA_ASSERT_THROW` to cause `TA_ASSERT` assertions to throw, `TA_ASSERT_ABORT` to cause `TA_ASSERT` assertions to abort. The default is `TA_ASSERT_IGNORE` if CMake uses a single-configuration generator and`CMAKE_BUILD_TYPE` is set to `Release` or `MinSizeRel`, else the default is `TA_ASSERT_THROW`. This is also forwarded to BTAS, as `BTAS_ASSERT_POLICY` (`TA_ASSERT_THROW`/`TA_ASSERT_ABORT`/`TA_ASSERT_IGNORE` map onto `BTAS_ASSERT_THROW`/`BTAS_ASSERT_ABORT`/`BTAS_ASSERT_IGNORE`), when BTAS is built from source; set `BTAS_ASSERT_POLICY` explicitly to override. +* `TA_ASSERT_POLICY` -- Set to `TA_ASSERT_IGNORE` to disable `TA_ASSERT` assertions, `TA_ASSERT_THROW` to cause `TA_ASSERT` assertions to throw, `TA_ASSERT_ABORT` to cause `TA_ASSERT` assertions to abort. The default is `TA_ASSERT_IGNORE` if CMake uses a single-configuration generator and`CMAKE_BUILD_TYPE` is set to `Release` or `MinSizeRel`, else the default is `TA_ASSERT_THROW`. This is also forwarded to BTAS, as `BTAS_ASSERT_POLICY` (`TA_ASSERT_THROW`/`TA_ASSERT_ABORT`/`TA_ASSERT_IGNORE` map onto `BTAS_ASSERT_THROW`/`BTAS_ASSERT_ABORT`/`BTAS_ASSERT_IGNORE`), when BTAS is built from source. An explicit `BTAS_ASSERT_POLICY` is honored and turns `TA_BTAS_ASSERT_POLICY_FOLLOWS_TA` (default `ON`) `OFF`, after which BTAS no longer follows TA; since CMake cannot distinguish an explicit `-DBTAS_ASSERT_POLICY=` from a cache entry that already holds ``, pin BTAS to a value TA derived on an earlier configure by also passing `-DTA_BTAS_ASSERT_POLICY_FOLLOWS_TA=OFF`. * `BUILD_TESTING` -- Set of `OFF` to disable building unit tests. The default is `ON`. * `TA_TRACE_TASKS` -- Set to `ON` to enable tracing of MADNESS tasks using custom task tracer. Note that standard profilers/tracers are generally useless (except in the trivial cases) with MADWorld-based programs since the submission context of tasks is not captured by standard tracing tools; this makes it impossible in a nontrivial program to attribute tasks to source code. WARNING: task tracing his will greatly increase the memory requirements. [Default=OFF]. * `TA_TTG` -- Set to `ON` to find or fetch the TTG library. [Default=OFF]. diff --git a/cmake/modules/FindOrFetchBTAS.cmake b/cmake/modules/FindOrFetchBTAS.cmake index 59298e4603..1ac631457c 100644 --- a/cmake/modules/FindOrFetchBTAS.cmake +++ b/cmake/modules/FindOrFetchBTAS.cmake @@ -32,24 +32,35 @@ if (NOT TARGET BTAS::BTAS) # (BTAS_ASSERT_THROW whenever BUILD_TESTING=ON, no matter what TA_ASSERT does). # BTAS_ASSERT_POLICY has the same three modes as TA_ASSERT_POLICY, and # like it is not affected by NDEBUG. - # N.B. only if the user did not ask for a specific BTAS_ASSERT_POLICY, hence a - # parent project that sets BTAS_ASSERT_POLICY first keeps control; - # a value that this module derived on an earlier configure (recorded in - # TA_BTAS_ASSERT_POLICY_DERIVED) is re-derived, so that reconfiguring - # with a different TA_ASSERT_POLICY keeps BTAS in sync - if (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) - set(_ta_btas_assert_policy BTAS_ASSERT_THROW) - elseif (TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT) - set(_ta_btas_assert_policy BTAS_ASSERT_ABORT) - else () - set(_ta_btas_assert_policy BTAS_ASSERT_IGNORE) + # TA_BTAS_ASSERT_POLICY_FOLLOWS_TA is the opt-out: while ON, BTAS_ASSERT_POLICY + # is (re)derived from TA_ASSERT_POLICY on every configure; an explicit + # BTAS_ASSERT_POLICY that differs from the value TA last acknowledged + # (recorded in TA_BTAS_ASSERT_POLICY_SEEN) is honored and turns the option OFF. + # N.B. CMake cannot tell an explicit -DBTAS_ASSERT_POLICY= from a cache + # entry that already holds X, so to pin BTAS to the value TA derived on + # an earlier configure pass -DTA_BTAS_ASSERT_POLICY_FOLLOWS_TA=OFF as well + set(_ta_btas_follow_doc "Derive BTAS_ASSERT_POLICY from TA_ASSERT_POLICY when BTAS is built from source; OFF leaves BTAS_ASSERT_POLICY to the user (or to BTAS's default)") + option(TA_BTAS_ASSERT_POLICY_FOLLOWS_TA "${_ta_btas_follow_doc}" ON) + if (TA_BTAS_ASSERT_POLICY_FOLLOWS_TA) + if (DEFINED BTAS_ASSERT_POLICY AND NOT (DEFINED TA_BTAS_ASSERT_POLICY_SEEN AND BTAS_ASSERT_POLICY STREQUAL TA_BTAS_ASSERT_POLICY_SEEN)) + # explicit user value (on the first configure, or changed since TA last saw it): honor it, stop following + set(TA_BTAS_ASSERT_POLICY_FOLLOWS_TA OFF CACHE BOOL "${_ta_btas_follow_doc}" FORCE) + message(STATUS "BTAS_ASSERT_POLICY=${BTAS_ASSERT_POLICY} was set explicitly: TA_BTAS_ASSERT_POLICY_FOLLOWS_TA turned OFF, BTAS_ASSERT_POLICY will no longer follow TA_ASSERT_POLICY") + else() + if (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) + set(BTAS_ASSERT_POLICY BTAS_ASSERT_THROW CACHE STRING "Controls the behavior of BTAS_ASSERT" FORCE) + elseif (TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT) + set(BTAS_ASSERT_POLICY BTAS_ASSERT_ABORT CACHE STRING "Controls the behavior of BTAS_ASSERT" FORCE) + else () + set(BTAS_ASSERT_POLICY BTAS_ASSERT_IGNORE CACHE STRING "Controls the behavior of BTAS_ASSERT" FORCE) + endif() + endif() endif() - if (NOT DEFINED BTAS_ASSERT_POLICY OR - (DEFINED TA_BTAS_ASSERT_POLICY_DERIVED AND BTAS_ASSERT_POLICY STREQUAL TA_BTAS_ASSERT_POLICY_DERIVED)) - set(BTAS_ASSERT_POLICY ${_ta_btas_assert_policy} CACHE STRING "Controls the behavior of BTAS_ASSERT" FORCE) - set(TA_BTAS_ASSERT_POLICY_DERIVED ${_ta_btas_assert_policy} CACHE INTERNAL "BTAS_ASSERT_POLICY derived from TA_ASSERT_POLICY by TiledArray") + if (DEFINED BTAS_ASSERT_POLICY) + # the value TA acknowledged (derived, or explicit); turning the option back ON with this value still in the cache resumes following + set(TA_BTAS_ASSERT_POLICY_SEEN ${BTAS_ASSERT_POLICY} CACHE INTERNAL "BTAS_ASSERT_POLICY last acknowledged by TiledArray") endif() - unset(_ta_btas_assert_policy) + unset(_ta_btas_follow_doc) include(FetchContent) FetchContent_Declare( From bcfddd8f2d41557ddc6ace79563df97f82a5aaf0 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Sep 2026 20:56:36 -0400 Subject: [PATCH 7/7] cmake: record the acknowledged BTAS_ASSERT_POLICY after BTAS is configured On a first configure with TA_BTAS_ASSERT_POLICY_FOLLOWS_TA=OFF and no explicit BTAS_ASSERT_POLICY the entry did not exist yet when the marker was recorded (BTAS creates it), so turning the option back ON later mistook BTAS's default for an explicit value. Record TA_BTAS_ASSERT_POLICY_SEEN after FetchContent_MakeAvailable(BTAS); spell out FORCE (INTERNAL already implies it). --- cmake/modules/FindOrFetchBTAS.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmake/modules/FindOrFetchBTAS.cmake b/cmake/modules/FindOrFetchBTAS.cmake index 1ac631457c..2a22516dfa 100644 --- a/cmake/modules/FindOrFetchBTAS.cmake +++ b/cmake/modules/FindOrFetchBTAS.cmake @@ -56,10 +56,6 @@ if (NOT TARGET BTAS::BTAS) endif() endif() endif() - if (DEFINED BTAS_ASSERT_POLICY) - # the value TA acknowledged (derived, or explicit); turning the option back ON with this value still in the cache resumes following - set(TA_BTAS_ASSERT_POLICY_SEEN ${BTAS_ASSERT_POLICY} CACHE INTERNAL "BTAS_ASSERT_POLICY last acknowledged by TiledArray") - endif() unset(_ta_btas_follow_doc) include(FetchContent) @@ -69,6 +65,14 @@ if (NOT TARGET BTAS::BTAS) GIT_TAG ${TA_TRACKED_BTAS_TAG} ) FetchContent_MakeAvailable(BTAS) + + # record the BTAS_ASSERT_POLICY value TA acknowledged (derived, explicit, or + # BTAS's own default when following is OFF): turning + # TA_BTAS_ASSERT_POLICY_FOLLOWS_TA back ON with this value still in the cache + # resumes following. Done after BTAS has been configured so that the entry + # exists even on a first configure with following OFF and no explicit value. + # N.B. INTERNAL implies FORCE; spelled out for clarity + set(TA_BTAS_ASSERT_POLICY_SEEN ${BTAS_ASSERT_POLICY} CACHE INTERNAL "BTAS_ASSERT_POLICY last acknowledged by TiledArray" FORCE) FetchContent_GetProperties(BTAS SOURCE_DIR BTAS_SOURCE_DIR BINARY_DIR BTAS_BINARY_DIR