From 27fb3272fd51cd69c453634096f7f16dc9498089 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 1 Jun 2025 13:28:26 +0200 Subject: [PATCH 1/3] Restore basic cmake features --- .github/workflows/ci_tests.yml | 8 +- CMakeLists.txt | 32 +-- Makefile | 2 +- cmake/appleclang-toolchain.cmake | 10 +- cmake/gnu-toolchain.cmake | 8 +- cmake/llvm-toolchain.cmake | 8 +- cmake/msvc-toolchain.cmake | 6 +- cmake/use-fetch-content.cmake | 249 ++++++++---------- docs/contributing.md | 4 +- docs/intro-examples.md | 2 +- docs/overview.md | 6 +- examples/CMakeLists.txt | 51 ++-- examples/intro-5-consumer.cpp | 8 +- .../execution/detail/forwarding_query.hpp | 2 +- src/beman/execution/CMakeLists.txt | 64 ++--- tests/beman/execution/CMakeLists.txt | 4 - 16 files changed, 220 insertions(+), 244 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 5009e0bc..a81e8787 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -38,7 +38,7 @@ jobs: - name: Setup build environment uses: lukka/get-cmake@latest with: - cmakeVersion: "~3.25.0" + cmakeVersion: "~3.28.0" ninjaVersion: "^1.11.1" - name: Setup MSVC if: startsWith(matrix.presets.platform, 'windows') @@ -106,7 +106,7 @@ jobs: - name: Install Ninja uses: lukka/get-cmake@latest with: - cmakeVersion: "~3.25.0" + cmakeVersion: "~3.28.0" ninjaVersion: "^1.11.1" - name: Setup MSVC if: startsWith(matrix.platform.os, 'windows') @@ -138,7 +138,7 @@ jobs: - name: Setup build environment uses: lukka/get-cmake@latest with: - cmakeVersion: "~3.25.0" + cmakeVersion: "~3.28.0" ninjaVersion: "^1.11.1" - name: Build and Test uses: ./.github/actions/cmake-build-test @@ -181,7 +181,7 @@ jobs: - name: Setup build environment uses: lukka/get-cmake@latest with: - cmakeVersion: "~3.25.0" + cmakeVersion: "~3.28.0" ninjaVersion: "^1.11.1" - name: Install Compiler id: install-compiler diff --git a/CMakeLists.txt b/CMakeLists.txt index 89d24ec2..00d7bec1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,39 +3,31 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # cmake-format: on -cmake_minimum_required(VERSION 3.25...3.31) +cmake_minimum_required(VERSION 3.28...4.0) -project( - beman.execution - DESCRIPTION "Beman implementation of asynchronous components" - LANGUAGES CXX - VERSION 0.0.1 -) +project(beman.execution DESCRIPTION "Beman implementation of asynchronous components" LANGUAGES CXX VERSION 0.0.2) -option( - BEMAN_EXECUTION_BUILD_TESTS - "Enable building tests and test infrastructure. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." - ${PROJECT_IS_TOP_LEVEL} +option(BEMAN_EXECUTION_BUILD_TESTS + "Enable building tests and test infrastructure. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." + ${PROJECT_IS_TOP_LEVEL} ) -option( - BEMAN_EXECUTION_BUILD_EXAMPLES - "Enable building examples. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." - ${PROJECT_IS_TOP_LEVEL} +option(BEMAN_EXECUTION_BUILD_EXAMPLES + "Enable building examples. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." ${PROJECT_IS_TOP_LEVEL} ) option( - BEMAN_EXECUTION_INSTALL_CONFIG_FILE_PACKAGE - "Enable creating and installing a CMake config-file package. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." - ${PROJECT_IS_TOP_LEVEL} + BEMAN_EXECUTION_INSTALL_CONFIG_FILE_PACKAGE + "Enable creating and installing a CMake config-file package. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." + ${PROJECT_IS_TOP_LEVEL} ) add_subdirectory(src/beman/execution) +enable_testing() + if(BEMAN_EXECUTION_BUILD_TESTS) - enable_testing() add_subdirectory(tests/beman/execution) endif() if(BEMAN_EXECUTION_BUILD_EXAMPLES) - enable_testing() add_subdirectory(examples) endif() diff --git a/Makefile b/Makefile index f8a956e7..111f1d6b 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ codespell: format: cmake-format clang-format cmake-format: - cmake-format -i `git diff --name-only main | egrep '(CMakeLists.txt|\.cmake)'` + git ls-files ::*.cmake ::*CMakeLists.txt | xargs cmake-format -i clang-format: git clang-format main diff --git a/cmake/appleclang-toolchain.cmake b/cmake/appleclang-toolchain.cmake index bc12103d..60520cf0 100644 --- a/cmake/appleclang-toolchain.cmake +++ b/cmake/appleclang-toolchain.cmake @@ -16,15 +16,13 @@ include_guard(GLOBAL) -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") - set(SANITIZER_FLAGS - "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" - ) + set(SANITIZER_FLAGS "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined") elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - set(SANITIZER_FLAGS "-fsanitize=thread") + set(SANITIZER_FLAGS "-fsanitize=thread") endif() set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") diff --git a/cmake/gnu-toolchain.cmake b/cmake/gnu-toolchain.cmake index b6dddf6a..8967954a 100644 --- a/cmake/gnu-toolchain.cmake +++ b/cmake/gnu-toolchain.cmake @@ -19,11 +19,11 @@ set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") - set(SANITIZER_FLAGS - "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fsanitize-undefined-trap-on-error" - ) + set(SANITIZER_FLAGS + "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fsanitize-undefined-trap-on-error" + ) elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - set(SANITIZER_FLAGS "-fsanitize=thread") + set(SANITIZER_FLAGS "-fsanitize=thread") endif() set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") diff --git a/cmake/llvm-toolchain.cmake b/cmake/llvm-toolchain.cmake index 5f5ee4b8..570c5c59 100644 --- a/cmake/llvm-toolchain.cmake +++ b/cmake/llvm-toolchain.cmake @@ -19,11 +19,11 @@ set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") - set(SANITIZER_FLAGS - "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fsanitize-undefined-trap-on-error" - ) + set(SANITIZER_FLAGS + "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fsanitize-undefined-trap-on-error" + ) elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - set(SANITIZER_FLAGS "-fsanitize=thread") + set(SANITIZER_FLAGS "-fsanitize=thread") endif() set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") diff --git a/cmake/msvc-toolchain.cmake b/cmake/msvc-toolchain.cmake index c2fffa79..91f9e58c 100644 --- a/cmake/msvc-toolchain.cmake +++ b/cmake/msvc-toolchain.cmake @@ -21,9 +21,9 @@ set(CMAKE_C_COMPILER cl) set(CMAKE_CXX_COMPILER cl) if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") - # /Zi flag (add debug symbol) is needed when using address sanitizer - # See C5072: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c5072 - set(SANITIZER_FLAGS "/fsanitize=address /Zi") + # /Zi flag (add debug symbol) is needed when using address sanitizer + # See C5072: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c5072 + set(SANITIZER_FLAGS "/fsanitize=address /Zi") endif() set(CMAKE_CXX_FLAGS_DEBUG_INIT "/EHsc /permissive- ${SANITIZER_FLAGS}") diff --git a/cmake/use-fetch-content.cmake b/cmake/use-fetch-content.cmake index a9130520..19fa916f 100644 --- a/cmake/use-fetch-content.cmake +++ b/cmake/use-fetch-content.cmake @@ -3,11 +3,7 @@ cmake_minimum_required(VERSION 3.24) include(FetchContent) if(NOT BEMAN_EXEMPLAR_LOCKFILE) - set(BEMAN_EXEMPLAR_LOCKFILE - "lockfile.json" - CACHE FILEPATH - "Path to the dependency lockfile for the Beman Exemplar." - ) + set(BEMAN_EXEMPLAR_LOCKFILE "lockfile.json" CACHE FILEPATH "Path to the dependency lockfile for the Beman Exemplar.") endif() set(BemanExemplar_projectDir "${CMAKE_CURRENT_LIST_DIR}/..") @@ -15,161 +11,140 @@ message(TRACE "BemanExemplar_projectDir=\"${BemanExemplar_projectDir}\"") message(TRACE "BEMAN_EXEMPLAR_LOCKFILE=\"${BEMAN_EXEMPLAR_LOCKFILE}\"") file( - REAL_PATH - "${BEMAN_EXEMPLAR_LOCKFILE}" - BemanExemplar_lockfile - BASE_DIRECTORY "${BemanExemplar_projectDir}" - EXPAND_TILDE + REAL_PATH "${BEMAN_EXEMPLAR_LOCKFILE}" BemanExemplar_lockfile BASE_DIRECTORY "${BemanExemplar_projectDir}" + EXPAND_TILDE ) message(DEBUG "Using lockfile: \"${BemanExemplar_lockfile}\"") # Force CMake to reconfigure the project if the lockfile changes set_property( - DIRECTORY "${BemanExemplar_projectDir}" - APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS "${BemanExemplar_lockfile}" + DIRECTORY "${BemanExemplar_projectDir}" APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${BemanExemplar_lockfile}" ) # For more on the protocol for this function, see: # https://cmake.org/cmake/help/latest/command/cmake_language.html#provider-commands function(BemanExemplar_provideDependency method package_name) - # Read the lockfile - file(READ "${BemanExemplar_lockfile}" BemanExemplar_rootObj) + # Read the lockfile + file(READ "${BemanExemplar_lockfile}" BemanExemplar_rootObj) + + # Get the "dependencies" field and store it in BemanExemplar_dependenciesObj + string( + JSON + BemanExemplar_dependenciesObj + ERROR_VARIABLE + BemanExemplar_error + GET + "${BemanExemplar_rootObj}" + "dependencies" + ) + if(BemanExemplar_error) + message(FATAL_ERROR "${BemanExemplar_lockfile}: ${BemanExemplar_error}") + endif() + + # Get the length of the libraries array and store it in BemanExemplar_dependenciesObj + string(JSON BemanExemplar_numDependencies ERROR_VARIABLE BemanExemplar_error + LENGTH "${BemanExemplar_dependenciesObj}" + ) + if(BemanExemplar_error) + message(FATAL_ERROR "${BemanExemplar_lockfile}: ${BemanExemplar_error}") + endif() + + # Loop over each dependency object + math(EXPR BemanExemplar_maxIndex "${BemanExemplar_numDependencies} - 1") + foreach(BemanExemplar_index RANGE "${BemanExemplar_maxIndex}") + set(BemanExemplar_errorPrefix "${BemanExemplar_lockfile}, dependency ${BemanExemplar_index}") + + # Get the dependency object at BemanExemplar_index + # and store it in BemanExemplar_depObj + string( + JSON + BemanExemplar_depObj + ERROR_VARIABLE + BemanExemplar_error + GET + "${BemanExemplar_dependenciesObj}" + "${BemanExemplar_index}" + ) + if(BemanExemplar_error) + message(FATAL_ERROR "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}") + endif() - # Get the "dependencies" field and store it in BemanExemplar_dependenciesObj + # Get the "name" field and store it in BemanExemplar_name string( - JSON - BemanExemplar_dependenciesObj - ERROR_VARIABLE BemanExemplar_error - GET "${BemanExemplar_rootObj}" - "dependencies" + JSON + BemanExemplar_name + ERROR_VARIABLE + BemanExemplar_error + GET + "${BemanExemplar_depObj}" + "name" ) if(BemanExemplar_error) - message(FATAL_ERROR "${BemanExemplar_lockfile}: ${BemanExemplar_error}") + message(FATAL_ERROR "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}") endif() - # Get the length of the libraries array and store it in BemanExemplar_dependenciesObj + # Get the "package_name" field and store it in BemanExemplar_pkgName string( - JSON - BemanExemplar_numDependencies - ERROR_VARIABLE BemanExemplar_error - LENGTH "${BemanExemplar_dependenciesObj}" + JSON + BemanExemplar_pkgName + ERROR_VARIABLE + BemanExemplar_error + GET + "${BemanExemplar_depObj}" + "package_name" ) if(BemanExemplar_error) - message(FATAL_ERROR "${BemanExemplar_lockfile}: ${BemanExemplar_error}") + message(FATAL_ERROR "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}") endif() - # Loop over each dependency object - math(EXPR BemanExemplar_maxIndex "${BemanExemplar_numDependencies} - 1") - foreach(BemanExemplar_index RANGE "${BemanExemplar_maxIndex}") - set(BemanExemplar_errorPrefix - "${BemanExemplar_lockfile}, dependency ${BemanExemplar_index}" - ) + # Get the "git_repository" field and store it in BemanExemplar_repo + string( + JSON + BemanExemplar_repo + ERROR_VARIABLE + BemanExemplar_error + GET + "${BemanExemplar_depObj}" + "git_repository" + ) + if(BemanExemplar_error) + message(FATAL_ERROR "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}") + endif() - # Get the dependency object at BemanExemplar_index - # and store it in BemanExemplar_depObj - string( - JSON - BemanExemplar_depObj - ERROR_VARIABLE BemanExemplar_error - GET "${BemanExemplar_dependenciesObj}" - "${BemanExemplar_index}" - ) - if(BemanExemplar_error) - message( - FATAL_ERROR - "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}" - ) - endif() - - # Get the "name" field and store it in BemanExemplar_name - string( - JSON - BemanExemplar_name - ERROR_VARIABLE BemanExemplar_error - GET "${BemanExemplar_depObj}" - "name" - ) - if(BemanExemplar_error) - message( - FATAL_ERROR - "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}" - ) - endif() - - # Get the "package_name" field and store it in BemanExemplar_pkgName - string( - JSON - BemanExemplar_pkgName - ERROR_VARIABLE BemanExemplar_error - GET "${BemanExemplar_depObj}" - "package_name" - ) - if(BemanExemplar_error) - message( - FATAL_ERROR - "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}" - ) - endif() - - # Get the "git_repository" field and store it in BemanExemplar_repo - string( - JSON - BemanExemplar_repo - ERROR_VARIABLE BemanExemplar_error - GET "${BemanExemplar_depObj}" - "git_repository" + # Get the "git_tag" field and store it in BemanExemplar_tag + string( + JSON + BemanExemplar_tag + ERROR_VARIABLE + BemanExemplar_error + GET + "${BemanExemplar_depObj}" + "git_tag" + ) + if(BemanExemplar_error) + message(FATAL_ERROR "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}") + endif() + + if(method STREQUAL "FIND_PACKAGE") + if(package_name STREQUAL BemanExemplar_pkgName) + string(APPEND BemanExemplar_debug "Redirecting find_package calls for ${BemanExemplar_pkgName} " + "to FetchContent logic fetching ${BemanExemplar_repo} at " + "${BemanExemplar_tag} according to ${BemanExemplar_lockfile}." ) - if(BemanExemplar_error) - message( - FATAL_ERROR - "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}" - ) - endif() - - # Get the "git_tag" field and store it in BemanExemplar_tag - string( - JSON - BemanExemplar_tag - ERROR_VARIABLE BemanExemplar_error - GET "${BemanExemplar_depObj}" - "git_tag" + message(DEBUG "${BemanExemplar_debug}") + FetchContent_Declare( + "${BemanExemplar_name}" GIT_REPOSITORY "${BemanExemplar_repo}" GIT_TAG "${BemanExemplar_tag}" + EXCLUDE_FROM_ALL ) - if(BemanExemplar_error) - message( - FATAL_ERROR - "${BemanExemplar_errorPrefix}: ${BemanExemplar_error}" - ) - endif() - - if(method STREQUAL "FIND_PACKAGE") - if(package_name STREQUAL BemanExemplar_pkgName) - string( - APPEND - BemanExemplar_debug - "Redirecting find_package calls for ${BemanExemplar_pkgName} " - "to FetchContent logic fetching ${BemanExemplar_repo} at " - "${BemanExemplar_tag} according to ${BemanExemplar_lockfile}." - ) - message(DEBUG "${BemanExemplar_debug}") - FetchContent_Declare( - "${BemanExemplar_name}" - GIT_REPOSITORY "${BemanExemplar_repo}" - GIT_TAG "${BemanExemplar_tag}" - EXCLUDE_FROM_ALL - ) - set(INSTALL_GTEST OFF) # Disable GoogleTest installation - FetchContent_MakeAvailable("${BemanExemplar_name}") - - # Important! _FOUND tells CMake that `find_package` is - # not needed for this package anymore - set("${BemanExemplar_pkgName}_FOUND" TRUE PARENT_SCOPE) - endif() - endif() - endforeach() + set(INSTALL_GTEST OFF) # Disable GoogleTest installation + FetchContent_MakeAvailable("${BemanExemplar_name}") + + # Important! _FOUND tells CMake that `find_package` is + # not needed for this package anymore + set("${BemanExemplar_pkgName}_FOUND" TRUE PARENT_SCOPE) + endif() + endif() + endforeach() endfunction() -cmake_language( - SET_DEPENDENCY_PROVIDER BemanExemplar_provideDependency - SUPPORTED_METHODS FIND_PACKAGE -) +cmake_language(SET_DEPENDENCY_PROVIDER BemanExemplar_provideDependency SUPPORTED_METHODS FIND_PACKAGE) diff --git a/docs/contributing.md b/docs/contributing.md index a99f5f25..cf71e632 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -17,9 +17,9 @@ incomplete list of starting points for contributions: created. * The [issues page](https://github.com/bemanproject/execution/issues) lists known issues. -* The implememtation of a component may be missing. +* The implementation of a component may be missing. * The layout of some pages related to the project can be improved. -* Some behaviour of a component isn't tested or documented. +* Some behavior of a component isn't tested or documented. * You found something which should be linked from the [resources](https://github.com/bemanproject/execution/blob/main/docs/resources.md) page. * There are [pull requests](https://github.com/bemanproject/execution/pulls) diff --git a/docs/intro-examples.md b/docs/intro-examples.md index 4e518654..e010ba61 100644 --- a/docs/intro-examples.md +++ b/docs/intro-examples.md @@ -17,7 +17,7 @@ synchronously produce the result. The intention is to show a basic use of some involved components to build up a feeling of how things work. -The componentes for `std::execution` are declared in the header +The components for `std::execution` are declared in the header ``. This particular implementation implements the cmponents in namespace `beman::execution` declared in the header ``: diff --git a/docs/overview.md b/docs/overview.md index 363b831a..b2c83f10 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -409,7 +409,7 @@ struct custom_t: forwarding_query_t { get_env(queryable) -> env **Default**: `empty_env`
-The expresion get_env(queryable) is used to get the environment env associated with queryable. To provide a non-default environment for a queryable a `get_env` member needs to be defined. If queryable doesn’t provide the get_env query an object of type empty_env is returned. +The expression get_env(queryable) is used to get the environment env associated with queryable. To provide a non-default environment for a queryable a `get_env` member needs to be defined. If queryable doesn’t provide the get_env query an object of type empty_env is returned. The value of the expression is
  1. the result of as_const(queryable).get_env() if this expression is valid and noexcept.
  2. empty_env otherwise. @@ -560,7 +560,7 @@ Otherwise the value is never_stop_token{}.
    connect(sender, receiver) -> operation_state -The expresion connect(sender, receiver) combines sender and receiver into an operation state state. When this state gets started using start(state) the operation represented by sender gets started and reports its completion to receiver or an object copied or moved from receiver. While the operation state state isn’t started it can be destroyed but once it got started it needs to stay valid until one of the completion signals is called on receiver. +The expression connect(sender, receiver) combines sender and receiver into an operation state state. When this state gets started using start(state) the operation represented by sender gets started and reports its completion to receiver or an object copied or moved from receiver. While the operation state state isn’t started it can be destroyed but once it got started it needs to stay valid until one of the completion signals is called on receiver.
    set_error(receiver, error) noexcept -> void @@ -655,7 +655,7 @@ The expression continues_on(sender, scheduler) create
    into_variant(sender) -> sender-of<set_value_t(std::variant<Tuple...>)> -The expression into_variant(sender) creates a sender which transforms the results of possibly multiple set_value completions of sender into one set_value completion respresenting the different upstream results as different options of a variant<Tuple...> where each Tuple is a tuple of values initialized with the respective arguments passed to set_value. The order of options in the variant isn’t specified. +The expression into_variant(sender) creates a sender which transforms the results of possibly multiple set_value completions of sender into one set_value completion representing the different upstream results as different options of a variant<Tuple...> where each Tuple is a tuple of values initialized with the respective arguments passed to set_value. The order of options in the variant isn’t specified.
    let_error(upstream, fun) -> sender diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index dcfd12e5..f5da850b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,21 +3,42 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # cmake-format: on -set( - EXAMPLES - inspect - playground - sender-demo - when_all-cancel - stop_token - stopping - allocator - intro-1-hello-world - intro-2-hello-async - intro-5-consumer - doc-just - doc-just_error - doc-just_stopped +cmake_minimum_required(VERSION 3.28...4.0) + +project(beman.execution.examples DESCRIPTION "Examaples for Beman implementation of asynchronous components" + LANGUAGES CXX VERSION 0.0.2 +) + +if(PROJECT_IS_TOP_LEVEL) + if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 23) + endif() + + find_package(beman.execution 0.0.2 EXACT) + if(NOT beman.execution_FOUND) + add_subdirectory(.. beman_execution) + endif() + + enable_testing() +endif() + +include(CMakePrintHelpers) +cmake_print_variables(CMAKE_CXX_STANDARD PROJECT_NAME PROJECT_VERSION PROJECT_SOURCE_DIR) + +set(EXAMPLES + inspect + playground + sender-demo + when_all-cancel + stop_token + stopping + allocator + intro-1-hello-world + intro-2-hello-async + intro-5-consumer + doc-just + doc-just_error + doc-just_stopped ) foreach(EXAMPLE ${EXAMPLES}) diff --git a/examples/intro-5-consumer.cpp b/examples/intro-5-consumer.cpp index 907847bb..360394aa 100644 --- a/examples/intro-5-consumer.cpp +++ b/examples/intro-5-consumer.cpp @@ -47,7 +47,7 @@ struct expected_to_channel_t { template struct state { using operation_state_concept = ex::operation_state_t; - using child_state_t = decltype(ex::connect(std::declval(), std::declval>())); + using child_state_t = decltype(ex::connect(std::declval(), std::declval >())); Receiver parent_receiver; child_state_t child_state; template @@ -73,17 +73,17 @@ struct expected_to_channel_t { CSender child_sender; template - state> connect(Receiver&& receiver) && { + state > connect(Receiver&& receiver) && { return {std::move(this->child_sender), std::forward(receiver)}; } template - state> connect(Receiver&& receiver) const& { + state > connect(Receiver&& receiver) const& { return {this->child_sender, std::forward(receiver)}; } }; template - sender> operator()(CSender&& child_sender) const { + sender > operator()(CSender&& child_sender) const { return {std::forward(child_sender)}; } auto operator()() const { return ex::detail::sender_adaptor{*this}; } diff --git a/include/beman/execution/detail/forwarding_query.hpp b/include/beman/execution/detail/forwarding_query.hpp index 360c13c5..8ef78c18 100644 --- a/include/beman/execution/detail/forwarding_query.hpp +++ b/include/beman/execution/detail/forwarding_query.hpp @@ -39,7 +39,7 @@ namespace beman::execution { */ using forwarding_query_t = beman::execution::detail::forwarding_query_t; /*! - * \brief The customizatoin point object to determine whether queries should be forwarded + * \brief The customization point object to determine whether queries should be forwarded * \headerfile beman/execution/execution.hpp * * \details diff --git a/src/beman/execution/CMakeLists.txt b/src/beman/execution/CMakeLists.txt index 32362e26..4ef85897 100644 --- a/src/beman/execution/CMakeLists.txt +++ b/src/beman/execution/CMakeLists.txt @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # cmake-format: on -include (GNUInstallDirs) +include(GNUInstallDirs) add_library(beman.execution STATIC) add_library(beman::execution ALIAS beman.execution) @@ -191,49 +191,43 @@ source_group("Header Files\\detail" FILES ${DETAIL_HEADER_FILES}) set_target_properties(beman.execution PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) target_compile_features(beman.execution PUBLIC - "$<$:cxx_std_26>" - "$<$>:cxx_std_23>" + "$<$:cxx_std_26>" + "$<$>:cxx_std_23>" ) install( - TARGETS beman.execution COMPONENT beman.execution - EXPORT beman.execution - DESTINATION $<$:debug/>${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION $<$:debug/>${CMAKE_INSTALL_BINDIR} - FILE_SET beman_execution_public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILE_SET beman_execution_detail_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + TARGETS beman.execution COMPONENT beman.execution + EXPORT beman.execution + DESTINATION $<$:debug/>${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION $<$:debug/>${CMAKE_INSTALL_BINDIR} + FILE_SET beman_execution_public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILE_SET beman_execution_detail_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) # cmake-format: on if(BEMAN_EXECUTION_INSTALL_CONFIG_FILE_PACKAGE) - include(CMakePackageConfigHelpers) + include(CMakePackageConfigHelpers) - configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/beman.execution-config.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/beman.execution-config.cmake" - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/beman.execution" - PATH_VARS PROJECT_NAME PROJECT_VERSION - ) + configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/beman.execution-config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/beman.execution-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/beman.execution" PATH_VARS PROJECT_NAME PROJECT_VERSION + ) - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/beman.execution-version.cmake" - VERSION ${PROJECT_VERSION} - COMPATIBILITY ExactVersion - ) + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/beman.execution-version.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion + ) - install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/beman.execution-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/beman.execution-version.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/beman.execution" - COMPONENT beman.execution - ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/beman.execution-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/beman.execution-version.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/beman.execution" COMPONENT beman.execution + ) - install( - EXPORT beman.execution - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/beman.execution" - NAMESPACE beman:: - FILE beman.execution-targets.cmake - COMPONENT beman.execution - ) + install( + EXPORT beman.execution + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/beman.execution" + NAMESPACE beman:: + FILE beman.execution-targets.cmake + COMPONENT beman.execution + ) endif() diff --git a/tests/beman/execution/CMakeLists.txt b/tests/beman/execution/CMakeLists.txt index 9f0b22c9..aef1c32e 100644 --- a/tests/beman/execution/CMakeLists.txt +++ b/tests/beman/execution/CMakeLists.txt @@ -94,10 +94,6 @@ list( include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -if(NOT DEFINED CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 23) -endif() - foreach(test ${execution_tests}) set(TEST_EXE beman.execution.${test}) add_executable(${TEST_EXE} ${test}.cpp) From d498a7e79d89a1358ab3f6a2d58c38d523711ac0 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 1 Jun 2025 15:09:44 +0200 Subject: [PATCH 2/3] Link required threads libs --- Makefile | 2 +- src/beman/execution/CMakeLists.txt | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 111f1d6b..bdc9bc22 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ clang-tidy: $(BUILD)/compile_commands.json run-clang-tidy -p $(BUILD) tests examples codespell: - codespell -L statics,snd,copyable,cancelled + codespell -w format: cmake-format clang-format diff --git a/src/beman/execution/CMakeLists.txt b/src/beman/execution/CMakeLists.txt index 4ef85897..231f51eb 100644 --- a/src/beman/execution/CMakeLists.txt +++ b/src/beman/execution/CMakeLists.txt @@ -5,6 +5,8 @@ include(GNUInstallDirs) +find_package(Threads REQUIRED) + add_library(beman.execution STATIC) add_library(beman::execution ALIAS beman.execution) @@ -189,11 +191,7 @@ get_property(DETAIL_HEADER_FILES TARGET beman.execution PROPERTY HEADER_SET_bema source_group("Header Files\\detail" FILES ${DETAIL_HEADER_FILES}) set_target_properties(beman.execution PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) - -target_compile_features(beman.execution PUBLIC - "$<$:cxx_std_26>" - "$<$>:cxx_std_23>" -) +target_link_libraries(beman.execution PUBLIC Threads::Threads) install( TARGETS beman.execution COMPONENT beman.execution From 98059d76a344a04787276f7e577f7cbef5cbf848 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 1 Jun 2025 17:48:35 +0200 Subject: [PATCH 3/3] Add runtime dependency --- Makefile | 10 +++++----- cmake/use-fetch-content.cmake | 3 ++- examples/CMakeLists.txt | 3 ++- src/beman/execution/beman.execution-config.cmake.in | 3 +++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index bdc9bc22..6a7219fc 100644 --- a/Makefile +++ b/Makefile @@ -80,9 +80,9 @@ doc: # $(MAKE) SANITIZER=$@ build: - CC=$(CXX) cmake --fresh -G Ninja -S $(SOURCEDIR) -B $(BUILD) $(TOOLCHAIN) $(SYSROOT) \ + CC=$(CXX) cmake --fresh -G Ninja -S $(SOURCEDIR) -B $(BUILD) $(TOOLCHAIN) $(SYSROOT) \ -D CMAKE_EXPORT_COMPILE_COMMANDS=1 \ - -D CMAKE_CXX_COMPILER=$(CXX) # XXX -D CMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)" + -D CMAKE_CXX_COMPILER=$(CXX) -D CMAKE_CXX_STANDARD=23 # XXX -D CMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)" cmake --build $(BUILD) test: build @@ -92,10 +92,10 @@ install: test cmake --install $(BUILD) --prefix $(INSTALL_PREFIX) release: - cmake --workflow --preset $@ --fresh + cmake --workflow --preset $(WORKFLOW)$@ --fresh debug: - cmake --workflow --preset $@ --fresh + cmake --workflow --preset $(WORKFLOW)$@ --fresh ce: @mkdir -p $(BUILD) @@ -123,7 +123,7 @@ codespell: format: cmake-format clang-format cmake-format: - git ls-files ::*.cmake ::*CMakeLists.txt | xargs cmake-format -i + git ls-files ::*.cmake ::*.cmake.in ::*CMakeLists.txt | xargs cmake-format -i clang-format: git clang-format main diff --git a/cmake/use-fetch-content.cmake b/cmake/use-fetch-content.cmake index 19fa916f..39885a15 100644 --- a/cmake/use-fetch-content.cmake +++ b/cmake/use-fetch-content.cmake @@ -147,4 +147,5 @@ function(BemanExemplar_provideDependency method package_name) endforeach() endfunction() -cmake_language(SET_DEPENDENCY_PROVIDER BemanExemplar_provideDependency SUPPORTED_METHODS FIND_PACKAGE) +# FIXME: Sinnfrei! +# cmake_language(SET_DEPENDENCY_PROVIDER BemanExemplar_provideDependency SUPPORTED_METHODS FIND_PACKAGE) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f5da850b..86a6b94e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,8 @@ if(PROJECT_IS_TOP_LEVEL) endif() include(CMakePrintHelpers) -cmake_print_variables(CMAKE_CXX_STANDARD PROJECT_NAME PROJECT_VERSION PROJECT_SOURCE_DIR) +cmake_print_variables(CMAKE_CXX_STANDARD CMAKE_PROJECT_NAME CMAKE_PROJECT_VERSION CMAKE_SOURCE_DIR) +cmake_print_variables(CMAKE_CXX_SCAN_FOR_MODULES PROJECT_NAME PROJECT_VERSION PROJECT_SOURCE_DIR) set(EXAMPLES inspect diff --git a/src/beman/execution/beman.execution-config.cmake.in b/src/beman/execution/beman.execution-config.cmake.in index 963f4e37..d0434c4e 100644 --- a/src/beman/execution/beman.execution-config.cmake.in +++ b/src/beman/execution/beman.execution-config.cmake.in @@ -1,5 +1,8 @@ set(BEMAN_EXECUTION_VERSION @PROJECT_VERSION@) +include(CMakeFindDependencyMacro) +find_dependency(Threads) + @PACKAGE_INIT@ include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)