diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index bede8f33..de206595 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -5,29 +5,7 @@ name: Linux Build on: push: - branches: ["main"] - paths: - - "include/**" - - "src/**" - - "tests/**" - - "examples/**" - - "cmake/**" - - "Makefile" - - "CMakePresets.json" - - "CMakeLists.txt" - - ".github/workflows/linux.yml" pull_request: - branches: ["main"] - paths: - - "include/**" - - "src/**" - - "tests/**" - - "examples/**" - - "cmake/**" - - "Makefile" - - "CMakePresets.json" - - "CMakeLists.txt" - - ".github/workflows/linux.yml" jobs: build: @@ -38,7 +16,8 @@ jobs: matrix: # TODO: sanitizer: [debug, release, asan, usan, tsan, lsan, msan] preset: [debug, release] - compiler: [g++-14, clang++-19] + # TODO: compiler: [g++-15, clang++-19] + compiler: [clang++-19] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index d4de55eb..55d2f907 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -5,29 +5,7 @@ name: Macos Build on: push: - branches: ["main"] - paths: - - "include/**" - - "src/**" - - "tests/**" - - "examples/**" - - "cmake/**" - - "Makefile" - - "CMakePresets.json" - - "CMakeLists.txt" - - ".github/workflows/macos.yml" pull_request: - branches: ["main"] - paths: - - "include/**" - - "src/**" - - "tests/**" - - "examples/**" - - "cmake/**" - - "Makefile" - - "CMakePresets.json" - - "CMakeLists.txt" - - ".github/workflows/macos.yml" jobs: build: @@ -37,8 +15,8 @@ jobs: matrix: preset: [debug, release] - # TODO: compiler: [g++, clang++-19] - compiler: [g++, clang++-18] + # TODO: compiler: [g++-15, clang++-19] + compiler: [clang++-19] steps: - uses: actions/checkout@v4 @@ -47,9 +25,6 @@ jobs: # if: startsWith(matrix.compiler, 'clang') uses: aminya/setup-cpp@v1 with: - # TODO: compiler: llvm-19 - # clangtidy: true - # cmake: true ninja: true - name: Install llvm-19 @@ -57,13 +32,13 @@ jobs: run: | brew install llvm@19 || echo ignored - - name: macos clang++-18 ${{ matrix.preset }} + - name: macos clang++-19 ${{ matrix.preset }} if: startsWith(matrix.compiler, 'clang') - run: CXX=$(brew --prefix llvm@18)/bin/clang++ cmake --workflow --preset ${{ matrix.preset }} + run: CXX=$(brew --prefix llvm@19)/bin/clang++ cmake --workflow --preset ${{ matrix.preset }} - - name: macos clang++-18 sanitizer + - name: macos clang++-19 sanitizer if: startsWith(matrix.compiler, 'clang') && startsWith(matrix.preset, 'debug') - run: CXX=$(brew --prefix llvm@18)/bin/clang++ make all + run: CXX=$(brew --prefix llvm@19)/bin/clang++ make all - name: macos g++ ${{ matrix.preset }} if: startsWith(matrix.compiler, 'g++') diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3474fcd2..0f9506dd 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -5,27 +5,7 @@ name: Windows Build on: push: - branches: ["main"] - paths: - - "include/**" - - "src/**" - - "tests/**" - - "examples/**" - - "cmake/**" - - "CMakePresets.json" - - "CMakeLists.txt" - - ".github/workflows/windows.yml" pull_request: - branches: ["main"] - paths: - - "include/**" - - "src/**" - - "tests/**" - - "examples/**" - - "cmake/**" - - "CMakePresets.json" - - "CMakeLists.txt" - - ".github/workflows/windows.yml" jobs: build: diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b1fdee4..84149c09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,15 +3,18 @@ # 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.30...3.31) -project(beman_execution26 VERSION 0.0.1 LANGUAGES CXX) +project(beman_execution26 VERSION 0.1.0 LANGUAGES CXX) if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "In-source builds are not allowed!") endif() -set(CMAKE_CXX_SCAN_FOR_MODULES ON) +# Note that scanning is only performed if C++20 or higher is enabled for the target. Scanning for modules in the target's +# sources belonging to file sets of type CXX_MODULES is always performed. +# not needed: set(CMAKE_CXX_SCAN_FOR_MODULES ON) + set(TARGET_NAME execution26) set(TARGET_NAMESPACE beman) # FIXME: not used in install(EXPORT ...) CK? set(TARGET_PREFIX ${TARGET_NAMESPACE}.${TARGET_NAME}) @@ -20,6 +23,9 @@ set(TARGET_ALIAS ${TARGET_LIBRARY}::${TARGET_LIBRARY}) set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config) set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets) +# This variable is a special case of the more-general CMAKE__POSTFIX variable for the DEBUG configuration. +set(CMAKE_DEBUG_POSTFIX D) + include(GNUInstallDirs) set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) @@ -56,7 +62,7 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug) ENABLE_SANITIZER_POINTER_COMPARE ENABLE_SANITIZER_POINTER_SUBTRACT ENABLE_CONTROL_FLOW_PROTECTION - ENABLE_STACK_PROTECTION + # XXX ENABLE_STACK_PROTECTION ENABLE_OVERFLOW_PROTECTION # ENABLE_ELF_PROTECTION # ENABLE_RUNTIME_SYMBOLS_RESOLUTION @@ -86,7 +92,7 @@ include(CMakePackageConfigHelpers) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake VERSION ${CMAKE_PROJECT_VERSION} - COMPATIBILITY AnyNewerVersion + COMPATIBILITY SameMajorVersion ) configure_package_config_file( diff --git a/cmake/CMakeGenericPresets.json b/cmake/CMakeGenericPresets.json index 7014512d..44fd4775 100644 --- a/cmake/CMakeGenericPresets.json +++ b/cmake/CMakeGenericPresets.json @@ -12,7 +12,7 @@ "type": "path", "value": "${sourceDir}/stagedir" }, - "CMAKE_CXX_EXTENSIONS": false, + "CMAKE_CXX_EXTENSIONS": true, "CMAKE_CXX_STANDARD": "23", "CMAKE_CXX_STANDARD_REQUIRED": true, "CMAKE_EXPORT_COMPILE_COMMANDS": true, diff --git a/examples/modules.cpp b/examples/modules.cpp index 9d5babe0..c76e60b2 100644 --- a/examples/modules.cpp +++ b/examples/modules.cpp @@ -3,12 +3,18 @@ // import std; #include +#include #if __cpp_modules < 201907L #include #else -import beman.execution26; +import beman_execution26; #endif namespace ex = beman::execution26; -int main() {} +int main() { + auto [result] = ex::sync_wait(ex::when_all(ex::just(std::string("hello, ")), ex::just(std::string("world"))) | + ex::then([](const auto& s1, const auto& s2) { return s1 + s2; })) + .value_or(std::tuple(std::string("oops"))); + std::cout << "result='" << result << "'\n"; +} diff --git a/src/beman/execution26/CMakeLists.txt b/src/beman/execution26/CMakeLists.txt index 12ba05f1..9380b125 100644 --- a/src/beman/execution26/CMakeLists.txt +++ b/src/beman/execution26/CMakeLists.txt @@ -7,7 +7,8 @@ add_library(${TARGET_LIBRARY} STATIC) add_library(${TARGET_ALIAS} ALIAS ${TARGET_LIBRARY}) if(CMAKE_BUILD_TYPE STREQUAL Debug) - target_link_libraries(${TARGET_LIBRARY} PUBLIC $) + # NOTE: Sanitizer or gcov is not possible for CXX_MODULES! CK + # XXX target_link_libraries(${TARGET_LIBRARY} PUBLIC $) target_link_libraries(${TARGET_LIBRARY} PUBLIC $) endif() @@ -188,33 +189,26 @@ target_compile_features(${TARGET_LIBRARY} PUBLIC ) target_sources( - beman_execution26 - PUBLIC FILE_SET - beman_execution26 TYPE CXX_MODULES FILES execution.cpp + ${TARGET_LIBRARY} + PUBLIC FILE_SET ${TARGET_LIBRARY}_modules + TYPE CXX_MODULES FILES execution.cppm ) -if(FALSE) install( TARGETS ${TARGET_LIBRARY} - EXPORT ${TARGETS_EXPORT_NAME}1 - ARCHIVE DESTINATION lib/$ + EXPORT ${TARGETS_EXPORT_NAME} + ARCHIVE # XXX DESTINATION lib/$ + FILE_SET ${TARGET_LIBRARY}_modules + # There's currently no convention for this location + DESTINATION ${INSTALL_CONFIGDIR}/src FILE_SET ${TARGET_LIBRARY}_public_headers FILE_SET ${TARGET_LIBRARY}_detail_headers ) install( - EXPORT ${TARGETS_EXPORT_NAME}1 - FILE ${TARGETS_EXPORT_NAME}.cmake + EXPORT ${TARGETS_EXPORT_NAME} DESTINATION "${INSTALL_CONFIGDIR}" + CXX_MODULES_DIRECTORY . NAMESPACE ${TARGET_LIBRARY}:: ) - -#-dk:TODO build/default/src/beman/execution26/CMakeFiles/beman_execution26.dir/beman.execution26.pcm -install( - TARGETS beman_execution26 - EXPORT beman_execution26 - COMPONENT FILE_SET beman_execution26 - DESTINATION lib/beman/execution26 -) -endif() -# cmake-format: on \ No newline at end of file +# cmake-format: on diff --git a/src/beman/execution26/execution.cpp b/src/beman/execution26/execution.cppm similarity index 99% rename from src/beman/execution26/execution.cpp rename to src/beman/execution26/execution.cppm index b79929ad..c1390eb9 100644 --- a/src/beman/execution26/execution.cpp +++ b/src/beman/execution26/execution.cppm @@ -8,7 +8,7 @@ module; #include #include -export module beman.execution26; +export module beman_execution26; namespace beman::execution26 { export int version(0); diff --git a/tests/beman/execution26/CMakeLists.txt b/tests/beman/execution26/CMakeLists.txt index 5e1c773f..8c8bcfce 100644 --- a/tests/beman/execution26/CMakeLists.txt +++ b/tests/beman/execution26/CMakeLists.txt @@ -1,6 +1,6 @@ # src/beman/execution26/tests/CMakeLists.txt # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.25...3.31) +cmake_minimum_required(VERSION 3.30...3.31) project(beman_execution26_tests LANGUAGES CXX) @@ -8,12 +8,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "In-source builds are not allowed!") endif() -list( - APPEND - execution_tests - execution-module.test - stop-token-module.test -) +list(APPEND execution_tests execution-module.test stop-token-module.test) list( APPEND @@ -113,9 +108,10 @@ endif() if(PROJECT_IS_TOP_LEVEL) enable_testing() - find_package(beman_execution26 0.0.1 EXACT QUIET) + find_package(beman_execution26 0.1.0 EXACT QUIET) if(beman_execution26_FOUND) - set(execution_tests exec-awaitable.test) # only one sample to save time! CK + set(execution_tests exec-awaitable.test) # only some samples to save time! CK + list(APPEND execution_tests execution-module.test) else() add_subdirectory(../../.. beman_execution26) @@ -133,27 +129,24 @@ foreach(test ${execution_tests}) add_test(NAME ${TEST_EXE} COMMAND $) endforeach() -if(FALSE) if(NOT PROJECT_IS_TOP_LEVEL) - # test if the targets are findable from the build directory + # test if the targets are findable from the install directory # cmake-format: off - add_test(NAME find-package-test - COMMAND ${CMAKE_CTEST_COMMAND} - # --verbose - --output-on-failure - -C $ - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-options - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" - "-DCMAKE_BUILD_TYPE=$" - "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" - # TODO(CK): Needed too? "--config $" - ) - # cmake-format: on -endif() +add_test(NAME find-package-test + COMMAND ${CMAKE_CTEST_COMMAND} + # --verbose + --output-on-failure + -C $ + --build-and-test + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-options + "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" + "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" + "-DCMAKE_BUILD_TYPE=$" + "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" +) +# cmake-format: on endif() diff --git a/tests/beman/execution26/execution-module.test.cpp b/tests/beman/execution26/execution-module.test.cpp index 70d3235b..d7604a7a 100644 --- a/tests/beman/execution26/execution-module.test.cpp +++ b/tests/beman/execution26/execution-module.test.cpp @@ -5,7 +5,7 @@ #if 0 #include #else -import beman.execution26; +import beman_execution26; #endif // ---------------------------------------------------------------------------- @@ -172,8 +172,8 @@ TEST(execution_modules) { // [exec.util.cmplsig.trans] //-dk:TODO template using transform_completion_signatures = - //test_stdex::transform_completion_signatures; -dk:TODO template using - //transform_completion_signatures_of = test_stdex::transform_completion_signatures_of; + // test_stdex::transform_completion_signatures; -dk:TODO template using + // transform_completion_signatures_of = test_stdex::transform_completion_signatures_of; // [exec.run.loop], run_loop test::use_type(); @@ -191,4 +191,4 @@ TEST(execution_modules) { // [exec.with.awaitable.senders] //-dk:TODO test::use_template(); -} \ No newline at end of file +} diff --git a/tests/beman/execution26/include/test/execution.hpp b/tests/beman/execution26/include/test/execution.hpp index 11be536a..4c6c08ed 100644 --- a/tests/beman/execution26/include/test/execution.hpp +++ b/tests/beman/execution26/include/test/execution.hpp @@ -16,7 +16,7 @@ namespace beman::execution26 {} -namespace beman::execution26::detail {}; +namespace beman::execution26::detail {} namespace test_std = ::beman::execution26; namespace test_stdex = ::beman::execution26; diff --git a/tests/beman/execution26/stop-token-module.test.cpp b/tests/beman/execution26/stop-token-module.test.cpp index 2bc4f94f..02756d97 100644 --- a/tests/beman/execution26/stop-token-module.test.cpp +++ b/tests/beman/execution26/stop-token-module.test.cpp @@ -5,7 +5,7 @@ #if 0 #include #else -import beman.execution26; +import beman_execution26; #endif // ---------------------------------------------------------------------------- @@ -39,4 +39,4 @@ TEST(stop_token_modules) { // [stopcallback.inplace], class template inplace_stop_callback test::use_template(); test::use_template(); -} \ No newline at end of file +}