Skip to content

Commit

Permalink
cmake: add gcov support for looking at test coverage
Browse files Browse the repository at this point in the history
This adds a cmake option for developers, which enables quick checking of
code coverage via gcov, making (hopefully) it easier to track test
cases, and what we should be doing for the next release.

Use this today to track down some iio_attr issues.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed Jun 4, 2020
1 parent cc26e6e commit bbc9411
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ if (MSVC)
add_compile_options(/WX)
endif()
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
option(WITH_GCOV "Build with gcov profiling flags" OFF)
if (WITH_GCOV)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
if(DEFINED ENV{CI} AND (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR}))
message(STATUS "Running in CI environment (Travis or AppVeyor), setting -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
Expand Down

0 comments on commit bbc9411

Please sign in to comment.