Skip to content

Commit 4f7452b

Browse files
committed
Add NDEBUG during code coverage to disable asserts
The macro 'assert' is implemented as a conditional which causes codecov think the line is always partially covered
1 parent 1bbf0f8 commit 4f7452b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ if(CODECOVERAGE)
3030
# for the given compiler. For example, with GCC, --coverage translates to
3131
# -fprofile-arcs -ftest-coverage when compiling and -lgcov when linking
3232
add_compile_options(--coverage -O0)
33+
# add NDEBUG to make sure asserts compile to a NOOP and do not negatively impact
34+
# code coverage. Asserts check invariants but since 'assert' is defined as a macro-condition,
35+
# codecov always considers it partially covered.
36+
add_compile_definitions(NDEBUG)
3337
add_link_options(--coverage)
3438
endif(CODECOVERAGE)
3539

0 commit comments

Comments
 (0)