1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
From a1f1536a20b698772adbae8d22aeacf5dc571854 Mon Sep 17 00:00:00 2001
From: Luca Weiss <luca@z3ntu.xyz>
Date: Sun, 30 Dec 2018 18:39:42 +0100
Subject: [PATCH] CMake cleanup
---
CMakeLists.txt | 2 +-
cmake/EnableCoverageReport.cmake | 153 -------------------------------
cmake/FindGtest.cmake | 53 -----------
cmake/FindLcov.cmake | 29 ------
cmake/Findgcovr.cmake | 31 -------
cmake/ParseArguments.cmake | 52 -----------
tests/CMakeLists.txt | 2 +-
7 files changed, 2 insertions(+), 320 deletions(-)
delete mode 100644 cmake/EnableCoverageReport.cmake
delete mode 100644 cmake/FindGtest.cmake
delete mode 100644 cmake/FindLcov.cmake
delete mode 100644 cmake/Findgcovr.cmake
delete mode 100644 cmake/ParseArguments.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c7394e..728b40a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,6 @@ project(properties-cpp)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
-include(cmake/EnableCoverageReport.cmake)
include(cmake/PrePush.cmake)
include(GNUInstallDirs)
@@ -42,4 +41,5 @@ add_subdirectory(data)
add_subdirectory(include)
add_subdirectory(tests)
+# find_package(CoverageReport)
# enable_coverage_report(posix_process_test linux_process_test)
diff --git a/cmake/EnableCoverageReport.cmake b/cmake/EnableCoverageReport.cmake
deleted file mode 100644
index b109ad4..0000000
--- a/cmake/EnableCoverageReport.cmake
+++ /dev/null
@@ -1,153 +0,0 @@
-# - Creates a special coverage build type and target on GCC.
-#
-# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
-# for selected targets. Optional arguments to this function are used to filter
-# unwanted results using globbing expressions. Moreover targets with tests for
-# the source code can be specified to trigger regenerating the report if the
-# test has changed
-#
-# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
-#
-# To generate a coverage report first build the project with
-# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
-#
-# The coverage report is based on gcov. Depending on the availability of lcov
-# a HTML report will be generated and/or an XML report of gcovr is found.
-# The generated coverage target executes all found solutions. Special targets
-# exist to create e.g. only the xml report: coverage-xml.
-#
-# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
-#
-# This program is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General
-# Public License as published by the Free Software Foundation;
-# either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-
-INCLUDE(ParseArguments)
-
-FIND_PACKAGE(Lcov)
-FIND_PACKAGE(gcovr)
-
-FUNCTION(ENABLE_COVERAGE_REPORT)
-
- # argument parsing
- PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN})
-
- SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
- SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
- SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
- SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
- SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
-
- # decide if there is any tool to create coverage data
- SET(TOOL_FOUND FALSE)
- IF(LCOV_FOUND OR GCOVR_FOUND)
- SET(TOOL_FOUND TRUE)
- ENDIF()
- IF(NOT TOOL_FOUND)
- MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
- ENDIF()
-
- STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
- IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
-
- MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}")
-
- # create coverage build type
- SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
- SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
- SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
-
- # instrument targets
- SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
- LINK_FLAGS --coverage)
-
- # html report
- IF (LCOV_FOUND)
-
- MESSAGE(STATUS "Enabling HTML coverage report")
-
- # set up coverage target
-
- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}
- COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE}
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- COMMENT "Collecting coverage data"
- DEPENDS ${ARG_TARGETS} ${ARG_TESTS}
- VERBATIM)
-
- # filter unwanted stuff
- LIST(LENGTH ARG_FILTER FILTER_LENGTH)
- IF(${FILTER_LENGTH} GREATER 0)
- SET(FILTER COMMAND ${LCOV_EXECUTABLE})
- FOREACH(F ${ARG_FILTER})
- SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F})
- ENDFOREACH()
- SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE})
- ELSE()
- SET(FILTER "")
- ENDIF()
-
- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE}
- COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE}
- ${FILTER}
- DEPENDS ${COVERAGE_RAW_FILE}
- COMMENT "Filtering recorded coverage data for project-relevant entries"
- VERBATIM)
- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR}
- COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE}
- DEPENDS ${COVERAGE_FILTERED_FILE}
- COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}"
- VERBATIM)
-
- ADD_CUSTOM_TARGET(coverage-html
- DEPENDS ${COVERAGE_REPORT_DIR})
-
- ENDIF()
-
- # xml coverage report
- IF(GCOVR_FOUND)
-
- MESSAGE(STATUS "Enabling XML coverage report")
-
- # gcovr cannot write directly to a file so the execution needs to
- # be wrapped in a cmake file that generates the file output
- FILE(WRITE ${COVERAGE_XML_COMMAND_FILE}
- "SET(ENV{LANG} en)\n")
- FILE(APPEND ${COVERAGE_XML_COMMAND_FILE}
- "EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" --exclude=tests.* --exclude=obj-.* --exclude=cmake.* -x -r \"${CMAKE_SOURCE_DIR}\" OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n")
-
- ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE}
- COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE}
- COMMENT "Generating coverage XML report"
- VERBATIM)
-
- ADD_CUSTOM_TARGET(coverage-xml
- DEPENDS ${COVERAGE_XML_FILE})
-
- ENDIF()
-
- # provide a global coverage target executing both steps if available
- SET(GLOBAL_DEPENDS "")
- IF(LCOV_FOUND)
- LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR})
- ENDIF()
- IF(GCOVR_FOUND)
- LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE})
- ENDIF()
- IF(LCOV_FOUND OR GCOVR_FOUND)
- ADD_CUSTOM_TARGET(coverage
- DEPENDS ${GLOBAL_DEPENDS})
- ENDIF()
-
- ENDIF()
-
-ENDFUNCTION()
diff --git a/cmake/FindGtest.cmake b/cmake/FindGtest.cmake
deleted file mode 100644
index 1283174..0000000
--- a/cmake/FindGtest.cmake
+++ /dev/null
@@ -1,53 +0,0 @@
-include(ExternalProject)
-include(FindPackageHandleStandardArgs)
-
-#gtest
-set(GTEST_INSTALL_DIR /usr/src/gmock/gtest/include)
-find_path(GTEST_INCLUDE_DIR gtest/gtest.h
- HINTS ${GTEST_INSTALL_DIR})
-
-#gmock
-find_path(GMOCK_INSTALL_DIR gmock/CMakeLists.txt
- HINTS /usr/src)
-if(${GMOCK_INSTALL_DIR} STREQUAL "GMOCK_INSTALL_DIR-NOTFOUND")
- message(FATAL_ERROR "google-mock package not found")
-endif()
-
-set(GMOCK_INSTALL_DIR ${GMOCK_INSTALL_DIR}/gmock)
-find_path(GMOCK_INCLUDE_DIR gmock/gmock.h)
-
-set(GMOCK_PREFIX gmock)
-set(GMOCK_BINARY_DIR ${CMAKE_BINARY_DIR}/${GMOCK_PREFIX}/libs)
-set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest)
-
-set(GTEST_CMAKE_ARGS "")
-if (${MIR_IS_CROSS_COMPILING})
- set(GTEST_CMAKE_ARGS
- -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake)
-endif()
-
-ExternalProject_Add(
- GMock
- #where to build in source tree
- PREFIX ${GMOCK_PREFIX}
- #where the source is external to the project
- SOURCE_DIR ${GMOCK_INSTALL_DIR}
- #forward the compilers to the subproject so cross-arch builds work
- CMAKE_ARGS ${GTEST_CMAKE_ARGS}
- BINARY_DIR ${GMOCK_BINARY_DIR}
-
- #we don't need to install, so skip
- INSTALL_COMMAND ""
-)
-
-set(GMOCK_LIBRARY ${GMOCK_BINARY_DIR}/libgmock.a)
-set(GMOCK_MAIN_LIBRARY ${GMOCK_BINARY_DIR}/libgmock_main.a)
-set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY})
-set(GTEST_LIBRARY ${GTEST_BINARY_DIR}/libgtest.a)
-set(GTEST_MAIN_LIBRARY ${GTEST_BINARY_DIR}/libgtest_main.a)
-set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY})
-set(GTEST_ALL_LIBRARIES ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
-
-find_package_handle_standard_args(GTest DEFAULT_MSG
- GMOCK_INCLUDE_DIR
- GTEST_INCLUDE_DIR)
diff --git a/cmake/FindLcov.cmake b/cmake/FindLcov.cmake
deleted file mode 100644
index 70628f4..0000000
--- a/cmake/FindLcov.cmake
+++ /dev/null
@@ -1,29 +0,0 @@
-# - Find lcov
-# Will define:
-#
-# LCOV_EXECUTABLE - the lcov binary
-# GENHTML_EXECUTABLE - the genhtml executable
-#
-# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
-#
-# This program is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General
-# Public License as published by the Free Software Foundation;
-# either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-
-INCLUDE(FindPackageHandleStandardArgs)
-
-FIND_PROGRAM(LCOV_EXECUTABLE lcov)
-FIND_PROGRAM(GENHTML_EXECUTABLE genhtml)
-
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE)
-
-# only visible in advanced view
-MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
diff --git a/cmake/Findgcovr.cmake b/cmake/Findgcovr.cmake
deleted file mode 100644
index e4c43fe..0000000
--- a/cmake/Findgcovr.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-# - Find gcovr scrip
-# Will define:
-#
-# GCOVR_EXECUTABLE - the gcovr script
-#
-# Uses:
-#
-# GCOVR_ROOT - root to search for the script
-#
-# Copyright (C) 2011 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
-#
-# This program is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General
-# Public License as published by the Free Software Foundation;
-# either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-
-INCLUDE(FindPackageHandleStandardArgs)
-
-FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
-
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE)
-
-# only visible in advanced view
-MARK_AS_ADVANCED(GCOVR_EXECUTABLE)
diff --git a/cmake/ParseArguments.cmake b/cmake/ParseArguments.cmake
deleted file mode 100644
index e13f671..0000000
--- a/cmake/ParseArguments.cmake
+++ /dev/null
@@ -1,52 +0,0 @@
-# Parse arguments passed to a function into several lists separated by
-# upper-case identifiers and options that do not have an associated list e.g.:
-#
-# SET(arguments
-# hello OPTION3 world
-# LIST3 foo bar
-# OPTION2
-# LIST1 fuz baz
-# )
-# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
-#
-# results in 7 distinct variables:
-# * ARG_DEFAULT_ARGS: hello;world
-# * ARG_LIST1: fuz;baz
-# * ARG_LIST2:
-# * ARG_LIST3: foo;bar
-# * ARG_OPTION1: FALSE
-# * ARG_OPTION2: TRUE
-# * ARG_OPTION3: TRUE
-#
-# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
-
-MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
- SET(DEFAULT_ARGS)
- FOREACH(arg_name ${arg_names})
- SET(${prefix}_${arg_name})
- ENDFOREACH(arg_name)
- FOREACH(option ${option_names})
- SET(${prefix}_${option} FALSE)
- ENDFOREACH(option)
-
- SET(current_arg_name DEFAULT_ARGS)
- SET(current_arg_list)
- FOREACH(arg ${ARGN})
- SET(larg_names ${arg_names})
- LIST(FIND larg_names "${arg}" is_arg_name)
- IF (is_arg_name GREATER -1)
- SET(${prefix}_${current_arg_name} ${current_arg_list})
- SET(current_arg_name ${arg})
- SET(current_arg_list)
- ELSE (is_arg_name GREATER -1)
- SET(loption_names ${option_names})
- LIST(FIND loption_names "${arg}" is_option)
- IF (is_option GREATER -1)
- SET(${prefix}_${arg} TRUE)
- ELSE (is_option GREATER -1)
- SET(current_arg_list ${current_arg_list} ${arg})
- ENDIF (is_option GREATER -1)
- ENDIF (is_arg_name GREATER -1)
- ENDFOREACH(arg)
- SET(${prefix}_${current_arg_name} ${current_arg_list})
-ENDMACRO(PARSE_ARGUMENTS)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 180498f..cb05b48 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,7 @@
set (OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# Don't treat warnings as errors in 3rd_party/{gmock,cucumber-cpp}
string (REPLACE " -Werror " " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
-find_package(Gtest REQUIRED)
+find_package(GTest REQUIRED)
include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})
set (CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS})
|