From c9a1dc5e68d543c46b9c139a13f8c5811b80014c Mon Sep 17 00:00:00 2001 From: Mathis Logemann <13556116+mathisloge@users.noreply.github.com> Date: Fri, 13 Mar 2026 22:48:35 +1100 Subject: [PATCH 1/4] Add options for STDEXEC installation and tests Add main project var to cmake --- CMakeLists.txt | 80 +++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e87dc5d42..04fe821ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,21 +82,32 @@ rapids_cmake_build_type(Release) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") +# Determine if STDEXEC is built as a subproject (using add_subdirectory) or if it is the main project. +if (NOT DEFINED STDEXEC_MAIN_PROJECT) + set(STDEXEC_MAIN_PROJECT OFF) + # Checking project name is more reliable than checking source directories. + if (NOT DEFINED PROJECT_NAME) + set(STDEXEC_MAIN_PROJECT ON) + endif () +endif () + # Don't build tests if configuring stdexec as a submodule of another # CMake project, unless they explicitly set STDEXEC_BUILD_TESTS=TRUE, # or they enabled CTest's BUILD_TESTING option -if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) OR BUILD_TESTING) +if (STDEXEC_MAIN_PROJECT OR BUILD_TESTING) set(STDEXEC_BUILD_TESTS_DEFAULT ON) else() set(STDEXEC_BUILD_TESTS_DEFAULT OFF) endif() option(STDEXEC_BUILD_TESTS "Build stdexec tests" ${STDEXEC_BUILD_TESTS_DEFAULT}) +option(STDEXEC_INSTALL "Generate the install target." ${STDEXEC_MAIN_PROJECT}) + # STDEXEC_BUILD_TESTS is used solely to configure CTest's BUILD_TESTING option, # which is CMake's preferred option for enabling testing when using CTest. set(BUILD_TESTING ${STDEXEC_BUILD_TESTS}) -if (BUILD_TESTING) +if (STDEXEC_BUILD_TESTS) # CTest automatically calls enable_testing() if BUILD_TESTING is ON # https://cmake.org/cmake/help/latest/module/CTest.html#module:CTest include(CTest) @@ -108,7 +119,7 @@ endif() # Initialize CPM rapids_cpm_init(OVERRIDE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/versions.json) -if (BUILD_TESTING) +if (STDEXEC_BUILD_TESTS) # Add Catch2 set(Catch2_VERSION 2.13.6) # Always download it, don't attempt to do `find_package(Catch2)` first @@ -199,7 +210,7 @@ set_target_properties(stdexec PROPERTIES VERSION "${STDEXEC_VERSION}" SOVERSION "${STDEXEC_VERSION_MAJOR}") -if (BUILD_TESTING) +if (STDEXEC_BUILD_TESTS) # Test that headers are self-contained set_target_properties(stdexec PROPERTIES VERIFY_INTERFACE_HEADER_SETS TRUE) @@ -492,33 +503,34 @@ endif() ############################################################################## # Install targets ------------------------------------------------------------ - -include(CPack) - -install(TARGETS stdexec system_context - EXPORT stdexec-exports - FILE_SET headers - FILE_SET version_config) - -############################################################################## -# Install exports ------------------------------------------------------------ - -set(code_string "") - -# Install side of the export set -rapids_export( - INSTALL ${stdexec_export_targets} - EXPORT_SET stdexec-exports - GLOBAL_TARGETS ${stdexec_export_targets} - NAMESPACE STDEXEC:: - FINAL_CODE_BLOCK code_string -) - -# Build side of the export set so a user can use the build dir as a CMake package root -rapids_export( - BUILD ${stdexec_export_targets} - EXPORT_SET stdexec-exports - GLOBAL_TARGETS ${stdexec_export_targets} - NAMESPACE STDEXEC:: - FINAL_CODE_BLOCK code_string -) +if(STDEXEC_INSTALL) + include(CPack) + + install(TARGETS stdexec system_context + EXPORT stdexec-exports + FILE_SET headers + FILE_SET version_config) + + ############################################################################## + # Install exports ------------------------------------------------------------ + + set(code_string "") + + # Install side of the export set + rapids_export( + INSTALL ${stdexec_export_targets} + EXPORT_SET stdexec-exports + GLOBAL_TARGETS ${stdexec_export_targets} + NAMESPACE STDEXEC:: + FINAL_CODE_BLOCK code_string + ) + + # Build side of the export set so a user can use the build dir as a CMake package root + rapids_export( + BUILD ${stdexec_export_targets} + EXPORT_SET stdexec-exports + GLOBAL_TARGETS ${stdexec_export_targets} + NAMESPACE STDEXEC:: + FINAL_CODE_BLOCK code_string + ) +endif() From 7a54193ffccdbcbf8ce64443896ced04056504c6 Mon Sep 17 00:00:00 2001 From: Mathis Logemann <13556116+mathisloge@users.noreply.github.com> Date: Fri, 13 Mar 2026 22:49:43 +1100 Subject: [PATCH 2/4] Conditionally install asioexec target based on STDEXEC_INSTALL --- cmake/Modules/ConfigureASIO.cmake | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cmake/Modules/ConfigureASIO.cmake b/cmake/Modules/ConfigureASIO.cmake index 210e5833c..779fad95f 100644 --- a/cmake/Modules/ConfigureASIO.cmake +++ b/cmake/Modules/ConfigureASIO.cmake @@ -57,10 +57,12 @@ if(STDEXEC_ENABLE_ASIO) STDEXEC::stdexec Boost::asio ) - install(TARGETS asioexec - EXPORT stdexec-exports - FILE_SET headers - ) + if(STDEXEC_INSTALL) + install(TARGETS asioexec + EXPORT stdexec-exports + FILE_SET headers + ) + endif() elseif(${STDEXEC_ASIO_USES_STANDALONE}) include(cmake/import_standalone_asio.cmake) @@ -93,10 +95,12 @@ if(STDEXEC_ENABLE_ASIO) STDEXEC::stdexec asio ) - install(TARGETS asioexec - EXPORT stdexec-exports - FILE_SET headers - ) + if(STDEXEC_INSTALL) + install(TARGETS asioexec + EXPORT stdexec-exports + FILE_SET headers + ) + endif() else() message(FATAL_ERROR "ASIO implementation is not configured") From b9a585fe83f3ccb642bc8d7fea9cac5aec423530 Mon Sep 17 00:00:00 2001 From: Mathis Logemann <13556116+mathisloge@users.noreply.github.com> Date: Fri, 13 Mar 2026 22:50:17 +1100 Subject: [PATCH 3/4] Conditionally install tbbexec based on STDEXEC_INSTALL --- cmake/Modules/ConfigureTBB.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/ConfigureTBB.cmake b/cmake/Modules/ConfigureTBB.cmake index d55373927..6678f61af 100644 --- a/cmake/Modules/ConfigureTBB.cmake +++ b/cmake/Modules/ConfigureTBB.cmake @@ -61,8 +61,10 @@ if (STDEXEC_ENABLE_TBB) STDEXEC::stdexec ) - install(TARGETS tbbexec - EXPORT stdexec-exports - FILE_SET headers - ) + if(STDEXEC_INSTALL) + install(TARGETS tbbexec + EXPORT stdexec-exports + FILE_SET headers + ) + endif() endif() From 88ccf54d8ed87a38013689a4a16481bd059924d4 Mon Sep 17 00:00:00 2001 From: Mathis Logemann <13556116+mathisloge@users.noreply.github.com> Date: Tue, 17 Mar 2026 17:49:13 +1100 Subject: [PATCH 4/4] Disable the tests by default unless it is the top level project and build testing was specified. --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04fe821ac..4f9e11b2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,10 +91,8 @@ if (NOT DEFINED STDEXEC_MAIN_PROJECT) endif () endif () -# Don't build tests if configuring stdexec as a submodule of another -# CMake project, unless they explicitly set STDEXEC_BUILD_TESTS=TRUE, -# or they enabled CTest's BUILD_TESTING option -if (STDEXEC_MAIN_PROJECT OR BUILD_TESTING) +# Disable the tests by default unless it is the top level project and build testing was specified. +if (STDEXEC_MAIN_PROJECT AND BUILD_TESTING) set(STDEXEC_BUILD_TESTS_DEFAULT ON) else() set(STDEXEC_BUILD_TESTS_DEFAULT OFF) @@ -479,7 +477,7 @@ if(STDEXEC_BUILD_DOCS) endif() # Configure test executables -if(BUILD_TESTING) +if(STDEXEC_BUILD_TESTS) add_subdirectory(test) endif()