Don't disable optimization when building with code coverage.
Make sure GCC links with gcov, like the docs says you should.
endif()
if(WITH_CODE_COVERAGE)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -coverage")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -coverage")
elseif(__GNUC__)
# Some versions of GCC don't support -coverage shorthand
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fprofile-arcs -ftest-coverage")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcov")
endif()
endif()