Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
build: fix building with coverage report
Browse files Browse the repository at this point in the history
Both ${SHELL_APP} variable and the target with that name is defined
later in the CMakeLists.txt, so the coverage enabling code has to move
down.
  • Loading branch information
peat-psuwit committed Jan 26, 2021
1 parent af17268 commit 43b3018
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@ if(cmake_build_type_lower MATCHES "debug")
endif()

find_package(CoverageReport)
#####################################################################
# Enable code coverage calculation with gcov/gcovr/lcov
# Usage:
# * Switch build type to coverage (use ccmake or cmake-gui)
# * Invoke make, make test, make coverage (or ninja if you use that backend)
# * Find html report in subdir coveragereport
# * Find xml report feasible for jenkins in coverage.xml
#####################################################################
if(cmake_build_type_lower MATCHES coverage)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" )
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
ENABLE_COVERAGE_REPORT(TARGETS ${SHELL_APP} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*)
endif()

find_package (ECM 1.7.0 QUIET NO_MODULE)
if (ECM_FOUND)
Expand Down Expand Up @@ -190,6 +175,22 @@ else()
message(STATUS "Tests disabled")
endif()

#####################################################################
# Enable code coverage calculation with gcov/gcovr/lcov
# Usage:
# * Switch build type to coverage (use ccmake or cmake-gui)
# * Invoke make, make test, make coverage (or ninja if you use that backend)
# * Find html report in subdir coveragereport
# * Find xml report feasible for jenkins in coverage.xml
#####################################################################
if(cmake_build_type_lower MATCHES coverage)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" )
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
ENABLE_COVERAGE_REPORT(TARGETS ${SHELL_APP} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*)
endif()

add_subdirectory(plugins)

#
Expand Down

0 comments on commit 43b3018

Please sign in to comment.