-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build system switched to cmake (#17)
- Loading branch information
Showing
9 changed files
with
119 additions
and
42 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: CMake | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
build_type: [Release, Debug] | ||
runs-on: ubuntu-latest | ||
env: | ||
BUILD_DIR: ${{github.workspace}}/build/${{matrix.build_type}} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Configure CMake | ||
run: cmake -B ${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} | ||
|
||
- name: Build | ||
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} | ||
|
||
- name: Test | ||
working-directory: ${{env.BUILD_DIR}} | ||
run: ctest -C ${{env.BUILD_TYPE}} | ||
|
||
- name: Generate coverage report | ||
if: ${{matrix.build_type == 'Debug'}} | ||
working-directory: ${{github.workspace}} | ||
run: | | ||
sudo apt-get install lcov | ||
lcov --base-directory . --directory ${{env.BUILD_DIR}} -c -o coverage.info | ||
lcov --remove coverage.info "test/*" -o coverage.info | ||
- name: Upload coverage to Codecov | ||
if: ${{matrix.build_type == 'Debug'}} | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
fail_ci_if_error: true | ||
verbose: true | ||
files: coverage.info | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
bin/ | ||
|
||
# Coverage dir | ||
build/ | ||
coverage/ | ||
|
||
# Coverage/profiling artifacts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_policy(SET CMP0048 NEW) | ||
|
||
cmake_minimum_required(VERSION 3.9) | ||
|
||
project(cpp_result VERSION 0.1) | ||
|
||
include_directories(include) | ||
|
||
add_subdirectory(test) | ||
add_subdirectory(examples) | ||
|
||
enable_testing() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
add_executable( | ||
example | ||
example.cpp | ||
) | ||
|
||
set_target_properties(example PROPERTIES CXX_STANDARD 14) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
add_executable( | ||
unit-tests | ||
result_test.cpp | ||
) | ||
|
||
enable_testing() | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG v1.14.0 | ||
) | ||
|
||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
|
||
FetchContent_MakeAvailable(googletest) | ||
|
||
set_target_properties(unit-tests PROPERTIES CXX_STANDARD 14) | ||
target_link_libraries(unit-tests GTest::gtest_main) | ||
target_compile_options(unit-tests PRIVATE -O0 --coverage -g) | ||
target_link_options(unit-tests PRIVATE --coverage) | ||
|
||
include(GoogleTest) | ||
|
||
gtest_discover_tests(unit-tests) |