Merge lp:~pete-woods/unity-scopes-api/cmake-extras-for-coverage-report into lp:unity-scopes-api/devel

Proposed by Pete Woods
Status: Merged
Approved by: dobey
Approved revision: 697
Merged at revision: 697
Proposed branch: lp:~pete-woods/unity-scopes-api/cmake-extras-for-coverage-report
Merge into: lp:unity-scopes-api/devel
Diff against target: 333 lines (+2/-281)
6 files modified
CMakeLists.txt (+1/-2)
cmake/modules/EnableCoverageReport.cmake (+0/-166)
cmake/modules/FindLcov.cmake (+0/-29)
cmake/modules/Findgcovr.cmake (+0/-31)
cmake/modules/ParseArguments.cmake (+0/-52)
debian/control.in (+1/-1)
To merge this branch: bzr merge lp:~pete-woods/unity-scopes-api/cmake-extras-for-coverage-report
Reviewer Review Type Date Requested Status
dobey (community) Approve
unity-api-1-bot continuous-integration Approve
Review via email: mp+317981@code.launchpad.net

Commit message

Use cmake-extras for coverage reporting

Description of the change

Use cmake-extras for coverage reporting

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:697
https://jenkins.canonical.com/unity-api-1/job/lp-unity-scopes-api-ci/69/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1699
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1706
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1481/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-unity-scopes-api-ci/69/rebuild

review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-04-06 23:27:51 +0000
3+++ CMakeLists.txt 2017-02-22 14:39:47 +0000
4@@ -14,7 +14,6 @@
5
6 include(CheckCXXSourceCompiles)
7 CHECK_CXX_SOURCE_COMPILES("#ifdef __clang__\n#else\n#error \"Not clang.\"\n#endif\nint main(int argc, char **argv) { return 0; }" IS_CLANG)
8-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
9
10 if(IS_CLANG)
11 message(STATUS "Compiling with Clang, disabling lttng.")
12@@ -290,7 +289,7 @@
13 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage -g")
14 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage -g")
15 endif()
16-include(EnableCoverageReport)
17+find_package(CoverageReport)
18
19 # Tests
20 include(CTest)
21
22=== removed directory 'cmake'
23=== removed directory 'cmake/modules'
24=== removed file 'cmake/modules/EnableCoverageReport.cmake'
25--- cmake/modules/EnableCoverageReport.cmake 2013-05-29 04:57:50 +0000
26+++ cmake/modules/EnableCoverageReport.cmake 1970-01-01 00:00:00 +0000
27@@ -1,166 +0,0 @@
28-# - Creates a special coverage build type and target on GCC.
29-#
30-# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
31-# for selected targets. Optional arguments to this function are used to filter
32-# unwanted results using globbing expressions. Moreover targets with tests for
33-# the source code can be specified to trigger regenerating the report if the
34-# test has changed
35-#
36-# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
37-#
38-# To generate a coverage report first build the project with
39-# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
40-#
41-# The coverage report is based on gcov. Depending on the availability of lcov
42-# a HTML report will be generated and/or an XML report of gcovr is found.
43-# The generated coverage target executes all found solutions. Special targets
44-# exist to create e.g. only the xml report: coverage-xml.
45-#
46-# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
47-#
48-# This program is free software; you can redistribute it
49-# and/or modify it under the terms of the GNU General
50-# Public License as published by the Free Software Foundation;
51-# either version 2, or (at your option)
52-# any later version.
53-#
54-# This program is distributed in the hope that it will be useful,
55-# but WITHOUT ANY WARRANTY; without even the implied warranty of
56-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57-# GNU General Public License for more details.
58-#
59-
60-INCLUDE(ParseArguments)
61-
62-FIND_PACKAGE(Lcov)
63-FIND_PACKAGE(gcovr)
64-
65-FUNCTION(ENABLE_COVERAGE_REPORT)
66-
67- # argument parsing
68- PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN})
69-
70- SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
71- SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
72- SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
73- SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
74- SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
75-
76- # decide if there is any tool to create coverage data
77- SET(TOOL_FOUND FALSE)
78- IF(LCOV_FOUND OR GCOVR_FOUND)
79- SET(TOOL_FOUND TRUE)
80- ENDIF()
81- IF(NOT TOOL_FOUND)
82- MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
83- ENDIF()
84-
85- STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
86- IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
87-
88- MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}")
89-
90- # create coverage build type
91- SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
92- SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
93- SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
94-
95- # instrument targets
96- SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
97- LINK_FLAGS --coverage)
98-
99- # html report
100- IF (LCOV_FOUND)
101-
102- MESSAGE(STATUS "Enabling HTML coverage report")
103-
104- # set up coverage target
105-
106- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}
107- COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE}
108- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
109- COMMENT "Collecting coverage data"
110- DEPENDS ${ARG_TARGETS} ${ARG_TESTS}
111- VERBATIM)
112-
113- # filter unwanted stuff
114- LIST(LENGTH ARG_FILTER FILTER_LENGTH)
115- IF(${FILTER_LENGTH} GREATER 0)
116- SET(FILTER COMMAND ${LCOV_EXECUTABLE})
117- FOREACH(F ${ARG_FILTER})
118- SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F})
119- ENDFOREACH()
120- SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE})
121- ELSE()
122- SET(FILTER "")
123- ENDIF()
124-
125- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE}
126- COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE}
127- ${FILTER}
128- DEPENDS ${COVERAGE_RAW_FILE}
129- COMMENT "Filtering recorded coverage data for project-relevant entries"
130- VERBATIM)
131- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR}
132- COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR}
133- COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE}
134- DEPENDS ${COVERAGE_FILTERED_FILE}
135- COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}"
136- VERBATIM)
137-
138- ADD_CUSTOM_TARGET(coverage-html
139- DEPENDS ${COVERAGE_REPORT_DIR})
140-
141- ENDIF()
142-
143- # xml coverage report
144- IF(GCOVR_FOUND)
145-
146- MESSAGE(STATUS "Enabling XML coverage report")
147-
148- # filter unwanted stuff
149- SET(GCOV_FILTER "")
150- LIST(LENGTH ARG_FILTER FILTER_LENGTH)
151- IF(${FILTER_LENGTH} GREATER 0)
152- FOREACH(F ${ARG_FILTER})
153- SET(GCOV_FILTER "${GCOV_FILTER} -e \"${F}\"")
154- ENDFOREACH()
155- ENDIF()
156-
157- # gcovr cannot write directly to a file so the execution needs to
158- # be wrapped in a cmake file that generates the file output
159- FILE(WRITE ${COVERAGE_XML_COMMAND_FILE}
160- "SET(ENV{LANG} en)\n")
161- FILE(APPEND ${COVERAGE_XML_COMMAND_FILE}
162- "EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" -x -r \"${CMAKE_SOURCE_DIR}\" ${GCOV_FILTER} OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n")
163-
164- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE}
165- COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE}
166- COMMENT "Generating coverage XML report"
167- VERBATIM)
168-
169- ADD_CUSTOM_TARGET(coverage-xml
170- DEPENDS ${COVERAGE_XML_FILE})
171-
172- ENDIF()
173-
174- # provide a global coverage target executing both steps if available
175- SET(GLOBAL_DEPENDS "")
176- IF(LCOV_FOUND)
177- LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR})
178- ENDIF()
179- IF(GCOVR_FOUND)
180- LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE})
181- ENDIF()
182- IF(LCOV_FOUND OR GCOVR_FOUND)
183- ADD_CUSTOM_TARGET(coverage
184- DEPENDS ${GLOBAL_DEPENDS})
185- ENDIF()
186-
187- ENDIF()
188-
189- # This gets rid of any stale .gcda files. Run this if a running a binary causes lots of messages about
190- # about a "merge mismatch for summaries".
191- ADD_CUSTOM_TARGET(clean-coverage COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f)
192-
193-ENDFUNCTION()
194
195=== removed file 'cmake/modules/FindLcov.cmake'
196--- cmake/modules/FindLcov.cmake 2013-05-29 04:57:50 +0000
197+++ cmake/modules/FindLcov.cmake 1970-01-01 00:00:00 +0000
198@@ -1,29 +0,0 @@
199-# - Find lcov
200-# Will define:
201-#
202-# LCOV_EXECUTABLE - the lcov binary
203-# GENHTML_EXECUTABLE - the genhtml executable
204-#
205-# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
206-#
207-# This program is free software; you can redistribute it
208-# and/or modify it under the terms of the GNU General
209-# Public License as published by the Free Software Foundation;
210-# either version 2, or (at your option)
211-# any later version.
212-#
213-# This program is distributed in the hope that it will be useful,
214-# but WITHOUT ANY WARRANTY; without even the implied warranty of
215-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
216-# GNU General Public License for more details.
217-#
218-
219-INCLUDE(FindPackageHandleStandardArgs)
220-
221-FIND_PROGRAM(LCOV_EXECUTABLE lcov)
222-FIND_PROGRAM(GENHTML_EXECUTABLE genhtml)
223-
224-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE)
225-
226-# only visible in advanced view
227-MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
228
229=== removed file 'cmake/modules/Findgcovr.cmake'
230--- cmake/modules/Findgcovr.cmake 2013-05-29 04:57:50 +0000
231+++ cmake/modules/Findgcovr.cmake 1970-01-01 00:00:00 +0000
232@@ -1,31 +0,0 @@
233-# - Find gcovr scrip
234-# Will define:
235-#
236-# GCOVR_EXECUTABLE - the gcovr script
237-#
238-# Uses:
239-#
240-# GCOVR_ROOT - root to search for the script
241-#
242-# Copyright (C) 2011 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
243-#
244-# This program is free software; you can redistribute it
245-# and/or modify it under the terms of the GNU General
246-# Public License as published by the Free Software Foundation;
247-# either version 2, or (at your option)
248-# any later version.
249-#
250-# This program is distributed in the hope that it will be useful,
251-# but WITHOUT ANY WARRANTY; without even the implied warranty of
252-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
253-# GNU General Public License for more details.
254-#
255-
256-INCLUDE(FindPackageHandleStandardArgs)
257-
258-FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
259-
260-FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE)
261-
262-# only visible in advanced view
263-MARK_AS_ADVANCED(GCOVR_EXECUTABLE)
264
265=== removed file 'cmake/modules/ParseArguments.cmake'
266--- cmake/modules/ParseArguments.cmake 2013-05-29 04:57:50 +0000
267+++ cmake/modules/ParseArguments.cmake 1970-01-01 00:00:00 +0000
268@@ -1,52 +0,0 @@
269-# Parse arguments passed to a function into several lists separated by
270-# upper-case identifiers and options that do not have an associated list e.g.:
271-#
272-# SET(arguments
273-# hello OPTION3 world
274-# LIST3 foo bar
275-# OPTION2
276-# LIST1 fuz baz
277-# )
278-# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
279-#
280-# results in 7 distinct variables:
281-# * ARG_DEFAULT_ARGS: hello;world
282-# * ARG_LIST1: fuz;baz
283-# * ARG_LIST2:
284-# * ARG_LIST3: foo;bar
285-# * ARG_OPTION1: FALSE
286-# * ARG_OPTION2: TRUE
287-# * ARG_OPTION3: TRUE
288-#
289-# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
290-
291-MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
292- SET(DEFAULT_ARGS)
293- FOREACH(arg_name ${arg_names})
294- SET(${prefix}_${arg_name})
295- ENDFOREACH(arg_name)
296- FOREACH(option ${option_names})
297- SET(${prefix}_${option} FALSE)
298- ENDFOREACH(option)
299-
300- SET(current_arg_name DEFAULT_ARGS)
301- SET(current_arg_list)
302- FOREACH(arg ${ARGN})
303- SET(larg_names ${arg_names})
304- LIST(FIND larg_names "${arg}" is_arg_name)
305- IF (is_arg_name GREATER -1)
306- SET(${prefix}_${current_arg_name} ${current_arg_list})
307- SET(current_arg_name ${arg})
308- SET(current_arg_list)
309- ELSE (is_arg_name GREATER -1)
310- SET(loption_names ${option_names})
311- LIST(FIND loption_names "${arg}" is_option)
312- IF (is_option GREATER -1)
313- SET(${prefix}_${arg} TRUE)
314- ELSE (is_option GREATER -1)
315- SET(current_arg_list ${current_arg_list} ${arg})
316- ENDIF (is_option GREATER -1)
317- ENDIF (is_arg_name GREATER -1)
318- ENDFOREACH(arg)
319- SET(${prefix}_${current_arg_name} ${current_arg_list})
320-ENDMACRO(PARSE_ARGUMENTS)
321
322=== modified file 'debian/control.in'
323--- debian/control.in 2016-11-28 05:06:26 +0000
324+++ debian/control.in 2017-02-22 14:39:47 +0000
325@@ -6,7 +6,7 @@
326 capnproto,
327 click-dev (>= 0.2.2),
328 cmake,
329- cmake-extras (>= 0.4),
330+ cmake-extras (>= 0.10),
331 dbus-test-runner,
332 debhelper (>= 9),
333 devscripts,

Subscribers

People subscribed via source and target branches

to all changes: