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

build: migrate CoverageReport to cmake-extras & fix its usage #358

Open
wants to merge 2 commits into
base: xenial
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,7 @@ if(cmake_build_type_lower MATCHES "debug")
add_definitions(-DQT_QML_DEBUG)
endif()

include(EnableCoverageReport)
#####################################################################
# 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(CoverageReport)

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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, only the ENABLE_COVERAGE_REPORT call needs to remain. The cmake-extras module will automatically add the --coverage arguments. So we can get rid of the extra stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like ENABLE_COVERAGE_REPORT also has the TESTS parameter. Am I supposed to put anything?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. It should list the tests targets. I guess we should refactor it a lot more to bubble up all the targets in a couple variables, from all the subdirs.


add_subdirectory(plugins)

#
Expand Down
166 changes: 0 additions & 166 deletions cmake/modules/EnableCoverageReport.cmake

This file was deleted.

29 changes: 0 additions & 29 deletions cmake/modules/FindLcov.cmake

This file was deleted.

31 changes: 0 additions & 31 deletions cmake/modules/Findgcovr.cmake

This file was deleted.

52 changes: 0 additions & 52 deletions cmake/modules/ParseArguments.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Maintainer: Ubuntu Developers <[email protected]>
Build-Depends:
android-headers,
cmake,
cmake-extras,
cmake-extras (>= 0.10),
dbus-test-runner,
debhelper (>= 9),
dh-apparmor,
Expand Down