diff --git a/CHANGELOG.md b/CHANGELOG.md index dc019564..e14e2325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ All notable changes to this project will be documented in this file. ### Changed +- Make std::execution optional via `HTOOL_WITH_STD_EXECUTION_API` macro to avoid linking with TBB. Default to false. + ### Fixed ## [1.0.2] - 2026-02-14 diff --git a/CMakeLists.txt b/CMakeLists.txt index 910f3e41..2d608906 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ endif() option(HTOOL_WITH_EXAMPLES "Build htool examples ?" ON) option(HTOOL_WITH_DOC "Build documentation" ON) option(HTOOL_WITH_STRICT_TESTS "Add -Werror to the tests" OFF) +option(HTOOL_WITH_STD_EXECUTION_API "Use std::execution API" OFF) #=============================================================================# #========================== External Libraries ===============================# @@ -144,6 +145,10 @@ if("${BLA_VENDOR}" STREQUAL "Intel10_32" target_compile_definitions(htool INTERFACE "-DHPDDM_MKL -DHTOOL_MKL") endif() +if(HTOOL_WITH_STD_EXECUTION_API) + target_compile_definitions(htool INTERFACE "-DHTOOL_WITH_STD_EXECUTION_API") +endif() + if(IS_INTEL_MKL) target_link_libraries(htool INTERFACE "-ltbb") endif() diff --git a/include/htool/hmatrix/execution_policies.hpp b/include/htool/hmatrix/execution_policies.hpp index c2f7fd57..94be1e8a 100644 --- a/include/htool/hmatrix/execution_policies.hpp +++ b/include/htool/hmatrix/execution_policies.hpp @@ -3,10 +3,10 @@ #include "hmatrix.hpp" #include -#if __has_include() +#if defined(HTOOL_WITH_STD_EXECUTION_API) && HTOOL_WITH_STD_EXECUTION_API && __has_include() # include #endif -#if defined(__cpp_lib_execution) && __cplusplus >= 201703L +#if defined(HTOOL_WITH_STD_EXECUTION_API) && HTOOL_WITH_STD_EXECUTION_API && __has_include() && defined(__cpp_lib_execution) && __cplusplus >= 201703L namespace exec_compat { using parallel_policy = std::execution::parallel_policy; inline constexpr auto par = std::execution::par;