Skip to content

Commit

Permalink
Added coverage flag to compiler options
Browse files Browse the repository at this point in the history
  • Loading branch information
mwthinker committed Jan 11, 2024
1 parent fd2649d commit f3c7b69
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Run CMake DEBUG
shell: bash
run: cmake --preset=${{ matrix.preset }} -B build_debug -DSignal_Test=1 -DSignal_Example=1 -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_BUILD_TYPE=Debug
run: cmake --preset=${{ matrix.preset }} -B build_debug -DSignal_Test=1 -DSignal_Example=1 -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=1

- name: Compile binaries DEBUG
shell: bash
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ set(SIGNAL_HEADERS

add_library(Signal INTERFACE)

option(CODE_COVERAGE "Enable coverage reporting" OFF)
if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(Signal INTERFACE --coverage)
target_link_options(Signal INTERFACE --coverage)
endif ()

target_include_directories(Signal
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
)

target_compile_features(Signal INTERFACE cxx_std_20)

message(STATUS "Signal_Test is available to add: -DSignal_Test=1")
Expand Down
55 changes: 25 additions & 30 deletions Signal_Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,33 @@ project(Signal_Test
)

find_package(GTest CONFIG REQUIRED)
if (GTest_FOUND)
enable_testing()
enable_testing()

add_executable(Signal_Test
src/signaltests.cpp
src/scopedconnectiontests.cpp
${SIGNAL_HEADERS}
)

target_link_libraries(Signal_Test
PUBLIC
Signal
GTest::gtest GTest::gtest_main # Test explorer on Visual Studio 2022 will not find test if "GTest::gmock_main GTest::gmock" is added?
)
add_executable(Signal_Test
src/signaltests.cpp
src/scopedconnectiontests.cpp
${SIGNAL_HEADERS}
)

if (MSVC)
target_compile_options(Signal_Test
PRIVATE
"/permissive-"
)
endif ()
target_link_libraries(Signal_Test
PUBLIC
Signal
GTest::gtest GTest::gtest_main # Test explorer on Visual Studio 2022 will not find test if "GTest::gmock_main GTest::gmock" is added?
)

set_target_properties(Signal_Test
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
if (MSVC)
target_compile_options(Signal_Test
PRIVATE
"/permissive-"
)

include(GoogleTest)
gtest_discover_tests(Signal_Test)

else ()
message(STATUS "GTest not found, Signal_Test not created")
endif ()

set_target_properties(Signal_Test
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)

include(GoogleTest)
gtest_discover_tests(Signal_Test)

0 comments on commit f3c7b69

Please sign in to comment.