Skip to content

Commit f71aeed

Browse files
Do coverage in clang so it can be done in release mode
1 parent 488ac53 commit f71aeed

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.github/workflows/sonarcloud.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ jobs:
5353
-GNinja \
5454
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
5555
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
56-
-DCMAKE_BUILD_TYPE=Debug \
56+
-DCMAKE_C_COMPILER=clang \
57+
-DCMAKE_CXX_COMPILER=clang++ \
58+
-DCMAKE_BUILD_TYPE=Release \
5759
-DBUILD_TESTS=ON \
5860
-DCI_BUILD=ON \
5961
-DENABLE_COVERAGE=ON \

src/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ if(ENABLE_COVERAGE)
4242
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
4343
message(WARNING "Coverage is enabled but not build in debug mode. Coverage results may be misleading.")
4444
endif()
45-
target_compile_options(nuclear PUBLIC -fprofile-arcs -ftest-coverage -fprofile-abs-path -fprofile-update=atomic)
46-
target_link_options(nuclear PUBLIC -fprofile-arcs)
45+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
46+
target_compile_options(nuclear PUBLIC -fprofile-arcs -ftest-coverage -fprofile-abs-path -fprofile-update=atomic)
47+
target_link_options(nuclear PUBLIC -fprofile-arcs)
48+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
49+
target_compile_options(nuclear PUBLIC -fprofile-instr-generate -fcoverage-mapping)
50+
target_link_options(nuclear PUBLIC -fprofile-instr-generate)
51+
else()
52+
message(FATAL_ERROR "Coverage is not supported for the current compiler.")
53+
endif()
4754
endif(ENABLE_COVERAGE)
4855

4956
# Enable warnings, and all warnings are errors

0 commit comments

Comments
 (0)