Merge lp:~kyrofa/unity-scope-click/utilize_cmake_extras into lp:unity-scope-click

Proposed by Kyle Fazzari on 2015-05-01
Status: Merged
Approved by: dobey on 2015-05-07
Approved revision: 322
Merged at revision: 322
Proposed branch: lp:~kyrofa/unity-scope-click/utilize_cmake_extras
Merge into: lp:unity-scope-click
Diff against target: 414 lines (+40/-254)
13 files modified
CMakeLists.txt (+7/-16)
HACKING (+3/-2)
cmake/EnableCoverageReport.cmake (+0/-158)
cmake/FindLcov.cmake (+0/-35)
cmake/Findgcovr.cmake (+0/-43)
debian/control (+1/-0)
libclickscope/tests/CMakeLists.txt (+4/-0)
libclickscope/tests/integration/CMakeLists.txt (+4/-0)
scope/tests/CMakeLists.txt (+5/-0)
scope/tests/click_interface_tool/CMakeLists.txt (+4/-0)
scope/tests/download_manager_tool/CMakeLists.txt (+4/-0)
scope/tests/fake_launcher/CMakeLists.txt (+4/-0)
tools/init-departments/CMakeLists.txt (+4/-0)
To merge this branch: bzr merge lp:~kyrofa/unity-scope-click/utilize_cmake_extras
Reviewer Review Type Date Requested Status
dobey (community) 2015-05-01 Approve on 2015-05-07
PS Jenkins bot continuous-integration Approve on 2015-05-06
Review via email: mp+258049@code.launchpad.net

Commit Message

Update to utilize cmake-extras.

Description of the Change

This change removes the "coverage" build type in favor of the "enable_coverage" cache variable to conform with standard cmake-extras usage.

To test:

1) Ensure gcov, lcov, and cmake-extras are installed.

2) Obtain coverage report:

$ cmake -Denable_coverage=ON path/to/src
$ make test
$ make coverage

3) Verify that an HTML coverage report has been generated in <build>/coveragereport/.

4) Clear out the build directory, and compile without the enable_coverage variable:

$ cmake /path/to/src
$ make test
$ make coverage # Should get "No rule to make target"

To post a comment you must log in.

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 2015-03-10 22:26:39 +0000
3+++ CMakeLists.txt 2015-05-07 13:58:21 +0000
4@@ -45,6 +45,8 @@
5 set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory")
6 set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")
7
8+option(enable_coverage "Add coverage targets.")
9+
10 add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
11
12 # Add our own subdirectories.
13@@ -56,22 +58,11 @@
14 add_subdirectory(po)
15 add_subdirectory(tools)
16
17-include(EnableCoverageReport) # Using gcov CMake modules from https://code.cor-lab.org/projects/rsc
18-#####################################################################
19-# Enable code coverage calculation with gcov/gcovr/lcov
20-# Usage:
21-# * Switch build type to coverage (use ccmake or cmake-gui)
22-# * Invoke make, make test, make coverage (or ninja if you use that backend)
23-# * Find html report in subdir coveragereport
24-# * Find xml report feasible for jenkins in coverage.xml
25-#####################################################################
26-string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower)
27-if(cmake_build_type_lower MATCHES coverage)
28- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
29- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
30- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" )
31- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
32- ENABLE_COVERAGE_REPORT(TARGETS ${SCOPE_LIB_UNVERSIONED} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*)
33+if(enable_coverage)
34+ include(EnableCoverageReport)
35+ ENABLE_COVERAGE_REPORT(TARGETS ${SCOPE_LIB_NAME} ${STORE_LIB_UNVERSIONED} ${APPS_LIB_UNVERSIONED}
36+ FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*
37+ )
38 endif()
39
40 # Custom targets for the tests
41
42=== modified file 'HACKING'
43--- HACKING 2014-08-18 15:32:41 +0000
44+++ HACKING 2015-05-07 13:58:21 +0000
45@@ -61,8 +61,9 @@
46 To run the coverage tests you'll need to install the gcovr and lcov packages.
47 Then you need to compile with coverage enabled, like this:
48
49- $ cmake .. -DCMAKE_BUILD_TYPE=coverage
50- $ make coverage-html
51+ $ cmake .. -Denable_coverage=ON
52+ $ make test
53+ $ make coverage
54
55 The html will be left on the coveragereport directory.
56
57
58=== removed file 'cmake/EnableCoverageReport.cmake'
59--- cmake/EnableCoverageReport.cmake 2014-05-02 22:11:12 +0000
60+++ cmake/EnableCoverageReport.cmake 1970-01-01 00:00:00 +0000
61@@ -1,158 +0,0 @@
62-# - Creates a special coverage build type and target on GCC.
63-#
64-# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
65-# for selected targets. Optional arguments to this function are used to filter
66-# unwanted results using globbing expressions. Moreover targets with tests for
67-# the source code can be specified to trigger regenerating the report if the
68-# test has changed
69-#
70-# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
71-#
72-# To generate a coverage report first build the project with
73-# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
74-#
75-# The coverage report is based on gcov. Depending on the availability of lcov
76-# a HTML report will be generated and/or an XML report of gcovr is found.
77-# The generated coverage target executes all found solutions. Special targets
78-# exist to create e.g. only the xml report: coverage-xml.
79-#
80-# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
81-#
82-# This file may be licensed under the terms of the
83-# GNU Lesser General Public License Version 3 (the ``LGPL''),
84-# or (at your option) any later version.
85-#
86-# Software distributed under the License is distributed
87-# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
88-# express or implied. See the LGPL for the specific language
89-# governing rights and limitations.
90-#
91-# You should have received a copy of the LGPL along with this
92-# program. If not, go to http://www.gnu.org/licenses/lgpl.html
93-# or write to the Free Software Foundation, Inc.,
94-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
95-#
96-# The development of this software was supported by:
97-# CoR-Lab, Research Institute for Cognition and Robotics
98-# Bielefeld University
99-
100-FIND_PACKAGE(Lcov)
101-FIND_PACKAGE(gcovr)
102-
103-FUNCTION(ENABLE_COVERAGE_REPORT)
104-
105- # argument parsing
106- SET(MULTI_VALUE_ARGS FILTER TARGETS TESTS)
107- CMAKE_PARSE_ARGUMENTS(ENABLE_COVERAGE_REPORT "" "" "${MULTI_VALUE_ARGS}" ${ARGN})
108-
109- SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
110- SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
111- SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
112- SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
113- SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
114-
115- # decide if there is any tool to create coverage data
116- SET(TOOL_FOUND FALSE)
117- IF(LCOV_FOUND OR GCOVR_FOUND)
118- SET(TOOL_FOUND TRUE)
119- ENDIF()
120- IF(NOT TOOL_FOUND)
121- MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
122- ENDIF()
123-
124- STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
125- IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
126-
127- MESSAGE(STATUS "Coverage support enabled for targets: ${ENABLE_COVERAGE_REPORT_TARGETS}")
128-
129- # create coverage build type
130- SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
131- SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
132- SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
133-
134- # instrument targets
135- SET_TARGET_PROPERTIES(${ENABLE_COVERAGE_REPORT_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
136- LINK_FLAGS --coverage)
137-
138- # html report
139- IF (LCOV_FOUND)
140-
141- MESSAGE(STATUS "Enabling HTML coverage report")
142-
143- # set up coverage target
144-
145- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}
146- COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE}
147- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
148- COMMENT "Collecting coverage data"
149- DEPENDS ${ENABLE_COVERAGE_REPORT_TARGETS} ${ENABLE_COVERAGE_REPORT_TESTS}
150- VERBATIM)
151-
152- # filter unwanted stuff
153- LIST(LENGTH ENABLE_COVERAGE_REPORT_FILTER FILTER_LENGTH)
154- IF(${FILTER_LENGTH} GREATER 0)
155- SET(FILTER COMMAND ${LCOV_EXECUTABLE})
156- FOREACH(F ${ENABLE_COVERAGE_REPORT_FILTER})
157- SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F})
158- ENDFOREACH()
159- SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE})
160- ELSE()
161- SET(FILTER "")
162- ENDIF()
163-
164- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE}
165- COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE}
166- ${FILTER}
167- DEPENDS ${COVERAGE_RAW_FILE}
168- COMMENT "Filtering recorded coverage data for project-relevant entries"
169- VERBATIM)
170- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR}
171- COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR}
172- COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE}
173- DEPENDS ${COVERAGE_FILTERED_FILE}
174- COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}"
175- VERBATIM)
176-
177- ADD_CUSTOM_TARGET(coverage-html
178- DEPENDS ${COVERAGE_REPORT_DIR})
179-
180- ENDIF()
181-
182- # xml coverage report
183- IF(GCOVR_FOUND)
184-
185- MESSAGE(STATUS "Enabling XML coverage report")
186-
187- # gcovr cannot write directly to a file so the execution needs to
188- # be wrapped in a cmake file that generates the file output
189- FILE(WRITE ${COVERAGE_XML_COMMAND_FILE}
190- "SET(ENV{LANG} en)\n")
191- FILE(APPEND ${COVERAGE_XML_COMMAND_FILE}
192- "EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" -x -r \"${CMAKE_SOURCE_DIR}\" OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n")
193-
194- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE}
195- COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE}
196- COMMENT "Generating coverage XML report"
197- VERBATIM)
198-
199- ADD_CUSTOM_TARGET(coverage-xml
200- DEPENDS ${COVERAGE_XML_FILE})
201-
202- ENDIF()
203-
204- # provide a global coverage target executing both steps if available
205- SET(GLOBAL_DEPENDS "")
206- IF(LCOV_FOUND)
207- LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR})
208- ENDIF()
209- IF(GCOVR_FOUND)
210- LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE})
211- ENDIF()
212- IF(LCOV_FOUND OR GCOVR_FOUND)
213- ADD_CUSTOM_TARGET(coverage
214- DEPENDS ${GLOBAL_DEPENDS})
215- ENDIF()
216-
217- ENDIF()
218-
219-ENDFUNCTION()
220
221=== removed file 'cmake/FindLcov.cmake'
222--- cmake/FindLcov.cmake 2014-05-02 22:11:12 +0000
223+++ cmake/FindLcov.cmake 1970-01-01 00:00:00 +0000
224@@ -1,35 +0,0 @@
225-# - Find lcov
226-# Will define:
227-#
228-# LCOV_EXECUTABLE - the lcov binary
229-# GENHTML_EXECUTABLE - the genhtml executable
230-#
231-# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
232-#
233-# This file may be licensed under the terms of the
234-# GNU Lesser General Public License Version 3 (the ``LGPL''),
235-# or (at your option) any later version.
236-#
237-# Software distributed under the License is distributed
238-# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
239-# express or implied. See the LGPL for the specific language
240-# governing rights and limitations.
241-#
242-# You should have received a copy of the LGPL along with this
243-# program. If not, go to http://www.gnu.org/licenses/lgpl.html
244-# or write to the Free Software Foundation, Inc.,
245-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
246-#
247-# The development of this software was supported by:
248-# CoR-Lab, Research Institute for Cognition and Robotics
249-# Bielefeld University
250-
251-INCLUDE(FindPackageHandleStandardArgs)
252-
253-FIND_PROGRAM(LCOV_EXECUTABLE lcov)
254-FIND_PROGRAM(GENHTML_EXECUTABLE genhtml)
255-
256-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE)
257-
258-# only visible in advanced view
259-MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
260
261=== removed file 'cmake/Findgcovr.cmake'
262--- cmake/Findgcovr.cmake 2014-05-02 22:11:12 +0000
263+++ cmake/Findgcovr.cmake 1970-01-01 00:00:00 +0000
264@@ -1,43 +0,0 @@
265-# - Find gcovr scrip
266-# Will define:
267-#
268-# GCOVR_EXECUTABLE - the gcovr script
269-#
270-# Uses:
271-#
272-# GCOVR_ROOT - root to search for the script
273-#
274-# Copyright (C) 2011 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
275-#
276-# This file may be licensed under the terms of the
277-# GNU Lesser General Public License Version 3 (the ``LGPL''),
278-# or (at your option) any later version.
279-#
280-# Software distributed under the License is distributed
281-# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
282-# express or implied. See the LGPL for the specific language
283-# governing rights and limitations.
284-#
285-# You should have received a copy of the LGPL along with this
286-# program. If not, go to http://www.gnu.org/licenses/lgpl.html
287-# or write to the Free Software Foundation, Inc.,
288-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
289-#
290-# The development of this software was supported by:
291-# CoR-Lab, Research Institute for Cognition and Robotics
292-# Bielefeld University
293-
294-INCLUDE(FindPackageHandleStandardArgs)
295-
296-FIND_PROGRAM(GCOVR_EXECUTABLE gcovr
297- HINTS ${GCOVR_ROOT}
298- "${GCOVR_ROOT}/bin"
299- "${GCOVR_ROOT}/share/python"
300- "/usr/share/python"
301- "/usr/local/share/python"
302- "${CMAKE_INSTALL_PREFIX}/share/python")
303-
304-FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE)
305-
306-# only visible in advanced view
307-MARK_AS_ADVANCED(GCOVR_EXECUTABLE)
308
309=== modified file 'debian/control'
310--- debian/control 2015-03-09 17:00:08 +0000
311+++ debian/control 2015-05-07 13:58:21 +0000
312@@ -4,6 +4,7 @@
313 # g++-4.9: since we use c++11 features, explicitly select a g++ version
314 # to protect from ABI breaks in libstdc++
315 Build-Depends: cmake (>= 2.8.10),
316+ cmake-extras,
317 debhelper (>= 9),
318 dh-translations,
319 g++-4.9:native,
320
321=== modified file 'libclickscope/tests/CMakeLists.txt'
322--- libclickscope/tests/CMakeLists.txt 2014-07-25 16:52:39 +0000
323+++ libclickscope/tests/CMakeLists.txt 2015-05-07 13:58:21 +0000
324@@ -57,6 +57,10 @@
325 ${CMAKE_THREAD_LIBS_INIT}
326 )
327
328+if(enable_coverage)
329+ target_link_libraries(${LIBCLICKSCOPE_TESTS_TARGET} gcov)
330+endif()
331+
332 add_custom_target (test-libclickscope
333 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIBCLICKSCOPE_TESTS_TARGET}
334 DEPENDS ${LIBCLICKSCOPE_TESTS_TARGET}
335
336=== modified file 'libclickscope/tests/integration/CMakeLists.txt'
337--- libclickscope/tests/integration/CMakeLists.txt 2014-07-22 17:15:14 +0000
338+++ libclickscope/tests/integration/CMakeLists.txt 2015-05-07 13:58:21 +0000
339@@ -26,6 +26,10 @@
340 ${CMAKE_THREAD_LIBS_INIT}
341 )
342
343+if(enable_coverage)
344+ target_link_libraries(${INTEGRATION_TARGET} gcov)
345+endif()
346+
347 add_custom_target (test-integration-click-scope
348 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${INTEGRATION_TARGET}
349 DEPENDS ${INTEGRATION_TARGET}
350
351=== modified file 'scope/tests/CMakeLists.txt'
352--- scope/tests/CMakeLists.txt 2014-10-01 15:10:28 +0000
353+++ scope/tests/CMakeLists.txt 2015-05-07 13:58:21 +0000
354@@ -64,6 +64,11 @@
355 ${CMAKE_THREAD_LIBS_INIT}
356 )
357
358+if(enable_coverage)
359+ target_link_libraries(${CLICKSCOPE_TESTS_TARGET} gcov)
360+ target_link_libraries(${APPS_SCOPE_TESTS_TARGET} gcov)
361+endif()
362+
363 add_custom_target (test-click-scope
364 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CLICKSCOPE_TESTS_TARGET}
365 DEPENDS ${CLICKSCOPE_TESTS_TARGET}
366
367=== modified file 'scope/tests/click_interface_tool/CMakeLists.txt'
368--- scope/tests/click_interface_tool/CMakeLists.txt 2014-05-26 15:56:40 +0000
369+++ scope/tests/click_interface_tool/CMakeLists.txt 2015-05-07 13:58:21 +0000
370@@ -12,3 +12,7 @@
371 target_link_libraries (${CLICK_INTERFACE_TOOL_TARGET}
372 ${STORE_LIB_UNVERSIONED}
373 )
374+
375+if(enable_coverage)
376+ target_link_libraries(${CLICK_INTERFACE_TOOL_TARGET} gcov)
377+endif()
378
379=== modified file 'scope/tests/download_manager_tool/CMakeLists.txt'
380--- scope/tests/download_manager_tool/CMakeLists.txt 2014-05-26 15:56:40 +0000
381+++ scope/tests/download_manager_tool/CMakeLists.txt 2015-05-07 13:58:21 +0000
382@@ -12,3 +12,7 @@
383 target_link_libraries (${DOWNLOAD_MANAGER_TOOL_TARGET}
384 ${STORE_LIB_UNVERSIONED}
385 )
386+
387+if(enable_coverage)
388+ target_link_libraries(${DOWNLOAD_MANAGER_TOOL_TARGET} gcov)
389+endif()
390
391=== modified file 'scope/tests/fake_launcher/CMakeLists.txt'
392--- scope/tests/fake_launcher/CMakeLists.txt 2014-06-17 18:02:15 +0000
393+++ scope/tests/fake_launcher/CMakeLists.txt 2015-05-07 13:58:21 +0000
394@@ -12,3 +12,7 @@
395 target_link_libraries (${FAKE_LAUNCHER_TARGET}
396 ${STORE_LIB_UNVERSIONED}
397 )
398+
399+if(enable_coverage)
400+ target_link_libraries(${FAKE_LAUNCHER_TARGET} gcov)
401+endif()
402
403=== modified file 'tools/init-departments/CMakeLists.txt'
404--- tools/init-departments/CMakeLists.txt 2014-08-15 14:03:20 +0000
405+++ tools/init-departments/CMakeLists.txt 2015-05-07 13:58:21 +0000
406@@ -20,4 +20,8 @@
407 ${CMAKE_THREAD_LIBS_INIT}
408 )
409
410+if(enable_coverage)
411+ target_link_libraries(${INITDEPTS} gcov)
412+endif()
413+
414 install(TARGETS ${INITDEPTS} DESTINATION sbin)

Subscribers

People subscribed via source and target branches

to all changes: