Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -83,18 +98,18 @@ 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
run: cmake --build . --config Debug --target tests

- 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 }}

Expand Down
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
THE SOFTWARE.
21 changes: 10 additions & 11 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand Down