diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6808ee2..74d5e11 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -29,24 +29,39 @@ jobs: matrix: config: - { - name: "Ubuntu Latest GCC (Release)", - os: ubuntu-latest, - build_type: "Release", + name: "Ubuntu 24.04 GCC, C++11 (Debug)", + os: ubuntu-24.04, + build_type: "Debug", + std: "11", + sanitizers: "ON", } - { - name: "Ubuntu 22.04 GCC (Debug)", - os: ubuntu-22.04, + name: "Ubuntu Latest GCC, C++17 (Debug)", + os: ubuntu-latest, build_type: "Debug", + std: "17", + sanitizers: "OFF", + } + - { + name: "Ubuntu Latest GCC, C++11 (Release)", + os: ubuntu-latest, + build_type: "Release", + std: "11", + sanitizers: "OFF", } - { - name: "macOS Latest Clang (Release)", + name: "macOS Latest Clang, C++11 (Release)", os: macos-latest, build_type: "Release", + std: "11", + sanitizers: "OFF", } - { - name: "Windows Latest (Release)", + name: "Windows Latest, C++11 (Release)", os: windows-latest, build_type: "Release", + std: "11", + sanitizers: "OFF", } steps: @@ -57,19 +72,19 @@ jobs: - name: Configure CMake working-directory: ${{github.workspace}}/build - run: cmake ${{ github.workspace }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -Dcpp_channel_build_examples=ON -Dcpp_channel_build_tests=ON + run: cmake ${{ github.workspace }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_CXX_STANDARD=${{ matrix.config.std }} -DCPP_CHANNEL_BUILD_EXAMPLES=ON -DCPP_CHANNEL_BUILD_TESTS=ON -DCPP_CHANNEL_SANITIZERS=${{ matrix.config.sanitizers }} - name: Build working-directory: ${{github.workspace}}/build - run: cmake --build . --config ${{ matrix.config.build_type }} --target tests + run: cmake --build . --config ${{ matrix.config.build_type }} --target tests -j - name: Test working-directory: ${{github.workspace}}/build - run: ctest -C ${{ matrix.config.build_type }} --verbose -R channel_test* + run: ctest -C ${{ matrix.config.build_type }} --verbose -R channel_test --output-on-failure -j - name: Run examples working-directory: ${{github.workspace}}/build - run: cmake --build . --config ${{ matrix.config.build_type }} --target examples + run: cmake --build . --config ${{ matrix.config.build_type }} --target examples -j coverage: name: Coverage @@ -83,7 +98,7 @@ jobs: - name: Configure CMake working-directory: ${{github.workspace}}/build - run: cmake ${{ github.workspace }} -DCMAKE_BUILD_TYPE=Debug -Dcpp_channel_build_tests=ON + run: cmake ${{ github.workspace }} -DCMAKE_BUILD_TYPE=Debug -DCPP_CHANNEL_BUILD_TESTS=ON -DCPP_CHANNEL_COVERAGE=ON - name: Build working-directory: ${{github.workspace}}/build @@ -91,10 +106,10 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build - run: ctest -C Debug --verbose -R channel_test11 + run: ctest -C Debug --verbose -R channel_test - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.0.1 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.vscode/settings.json b/.vscode/settings.json index 31c655f..c8217dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,10 @@ { "cmake.configureArgs": [ - "-Dcpp_channel_build_examples=ON", - "-Dcpp_channel_build_tests=ON" + "-DCPP_CHANNEL_BUILD_EXAMPLES=ON", + "-DCPP_CHANNEL_BUILD_TESTS=ON", + "-DCPP_CHANNEL_COVERAGE=ON", + "-DCPP_CHANNEL_SANITIZERS=ON", + "-DCMAKE_CXX_STANDARD=11" ], "clang-tidy.fixOnSave": false, "clang-tidy.lintOnSave": false, diff --git a/CMakeLists.txt b/CMakeLists.txt index b1be169..f124e51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12) project(cpp_channel) set(PROJECT_VERSION 0.8.3) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard") set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CXX_EXTENSIONS NO) @@ -14,14 +14,16 @@ include_directories(include) add_library(msd_channel INTERFACE) target_include_directories(msd_channel INTERFACE include) -option(cpp_channel_build_tests "Build all of cpp_channel's own tests." OFF) -option(cpp_channel_build_examples "Build cpp_channel's example programs." OFF) +option(CPP_CHANNEL_BUILD_TESTS "Build all of cpp_channel's own tests." OFF) +option(CPP_CHANNEL_BUILD_EXAMPLES "Build cpp_channel's example programs." OFF) +option(CPP_CHANNEL_COVERAGE "Generate test coverage." OFF) +option(CPP_CHANNEL_SANITIZERS "Build with sanitizers." OFF) -if (cpp_channel_build_tests) +if (CPP_CHANNEL_BUILD_TESTS) enable_testing() add_subdirectory(tests) endif() -if (cpp_channel_build_examples) +if (CPP_CHANNEL_BUILD_EXAMPLES) add_subdirectory(examples) endif() diff --git a/LICENSE b/LICENSE index 72e5ace..999d4e0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2023 Andrei Avram +Copyright (c) 2020-2025 Andrei Avram Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d0d4893..1a70fa2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,9 +23,14 @@ function(package_add_test TESTNAME) set_target_warnings(${TESTNAME} PRIVATE) target_link_libraries(${TESTNAME} gtest gtest_main) - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_link_libraries(${TESTNAME} -lgcov -lubsan) - target_compile_options(${TESTNAME} PRIVATE --coverage -fsanitize=undefined) + if (CPP_CHANNEL_COVERAGE) + target_link_libraries(${TESTNAME} -lgcov) + target_compile_options(${TESTNAME} PRIVATE --coverage) + endif () + + if (CPP_CHANNEL_SANITIZERS) + target_link_libraries(${TESTNAME} -lubsan) + target_compile_options(${TESTNAME} PRIVATE -fsanitize=undefined) endif () add_test(NAME ${TESTNAME} COMMAND ${TESTNAME}) @@ -36,17 +41,11 @@ endfunction() add_custom_target(tests) # Tests -package_add_test(channel_test11 channel_test.cpp blocking_iterator_test.cpp) -package_add_test(channel_test14 channel_test.cpp blocking_iterator_test.cpp) -package_add_test(channel_test17 channel_test.cpp blocking_iterator_test.cpp) - -set_target_properties(channel_test14 PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED YES) -set_target_properties(channel_test17 PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES) +package_add_test(channel_test channel_test.cpp blocking_iterator_test.cpp) if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") # Disable warnings about C++17 extensions - target_compile_options(channel_test11 PRIVATE -Wno-c++17-extensions) - target_compile_options(channel_test14 PRIVATE -Wno-c++17-extensions) + target_compile_options(channel_test PRIVATE -Wno-c++17-extensions) endif() # Benchmark