This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
354 lines (315 loc) · 12.4 KB
/
CMakeLists.txt
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
# Autogenerated by `mkbuild`; DO NOT EDIT!
cmake_minimum_required(VERSION 3.12.0)
project("mkcollector")
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
include(CheckCXXCompilerFlag)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
list(APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads)
if(("${WIN32}"))
list(APPEND CMAKE_REQUIRED_LIBRARIES ws2_32 crypt32)
endif()
enable_testing()
if(("${WIN32}"))
if(("${CMAKE_SIZEOF_VOID_P}" EQUAL 4))
SET(MK_WIN32_ARCH "x86")
elseif(("${CMAKE_SIZEOF_VOID_P}" EQUAL 8))
SET(MK_WIN32_ARCH "x64")
else()
message(FATAL_ERROR "Neither 32 not 64 bit")
endif()
endif()
if((${APPLE}))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib")
endif()
include(CheckFunctionExists)
include(CheckSymbolExists)
#
# catch.hpp
#
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include"
RESULT_VARIABLE FAILURE_1360)
if("${FAILURE_1360}")
message(FATAL_ERROR "${FAILURE_1360}")
endif()
message(STATUS "download: https://github.com/catchorg/Catch2/releases/download/v2.8.0/catch.hpp")
file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v2.8.0/catch.hpp
"${CMAKE_BINARY_DIR}/.mkbuild/include/catch.hpp"
EXPECTED_HASH SHA256=2791047e459b981a1035f4ee16a2ad031f5bfb4ba66487ad4d3fc816c8946f61
TLS_VERIFY ON)
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include")
CHECK_INCLUDE_FILE_CXX("catch.hpp" MK_HAVE_HEADER_1877)
if(NOT ("${MK_HAVE_HEADER_1877}"))
message(FATAL_ERROR "cannot find: catch.hpp")
endif()
if(("${WIN32}"))
#
# windows-curl-7.61.1-1.tar.gz
#
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/download")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_2258)
if("${FAILURE_2258}")
message(FATAL_ERROR "${FAILURE_2258}")
endif()
message(STATUS "download: https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-curl-7.61.1-1.tar.gz")
file(DOWNLOAD https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-curl-7.61.1-1.tar.gz
"${CMAKE_BINARY_DIR}/.mkbuild/download/windows-curl-7.61.1-1.tar.gz"
EXPECTED_HASH SHA256=424d2f18f0f74dd6a0128f0f4e59860b7d2f00c80bbf24b2702e9cac661357cf
TLS_VERIFY ON)
message(STATUS "Extract: ${CMAKE_BINARY_DIR}/.mkbuild/download/windows-curl-7.61.1-1.tar.gz")
execute_process(COMMAND
${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/.mkbuild/download/windows-curl-7.61.1-1.tar.gz"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_3081)
if("${FAILURE_3081}")
message(FATAL_ERROR "${FAILURE_3081}")
endif()
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/include")
CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_3326)
if(NOT ("${MK_HAVE_HEADER_3326}"))
message(FATAL_ERROR "cannot find: curl/curl.h")
endif()
CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib" "curl_easy_init" "" MK_HAVE_LIB_3485)
if(NOT ("${MK_HAVE_LIB_3485}"))
message(FATAL_ERROR "cannot find: ${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib")
endif()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib")
LIST(APPEND CMAKE_REQUIRED_DEFINITIONS -DCURL_STATICLIB)
else()
CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_4043)
if(NOT ("${MK_HAVE_HEADER_4043}"))
message(FATAL_ERROR "cannot find: curl/curl.h")
endif()
CHECK_LIBRARY_EXISTS("curl" "curl_easy_init" "" MK_HAVE_LIB_4202)
if(NOT ("${MK_HAVE_LIB_4202}"))
message(FATAL_ERROR "cannot find: curl")
endif()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "curl")
endif()
#
# generic-assets-20190520205742.tar.gz
#
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/download")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_4626)
if("${FAILURE_4626}")
message(FATAL_ERROR "${FAILURE_4626}")
endif()
message(STATUS "download: https://github.com/measurement-kit/generic-assets/releases/download/20190520205742/generic-assets-20190520205742.tar.gz")
file(DOWNLOAD https://github.com/measurement-kit/generic-assets/releases/download/20190520205742/generic-assets-20190520205742.tar.gz
"${CMAKE_BINARY_DIR}/.mkbuild/download/generic-assets-20190520205742.tar.gz"
EXPECTED_HASH SHA256=70d590c20b2ed31fd43cc63709b267672fecfeac7e908d11e845664ddd43b04f
TLS_VERIFY ON)
message(STATUS "Extract: ${CMAKE_BINARY_DIR}/.mkbuild/download/generic-assets-20190520205742.tar.gz")
execute_process(COMMAND
${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/.mkbuild/download/generic-assets-20190520205742.tar.gz"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_5487)
if("${FAILURE_5487}")
message(FATAL_ERROR "${FAILURE_5487}")
endif()
#
# mkbouncer.hpp
#
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include"
RESULT_VARIABLE FAILURE_5777)
if("${FAILURE_5777}")
message(FATAL_ERROR "${FAILURE_5777}")
endif()
message(STATUS "download: https://raw.githubusercontent.com/measurement-kit/mkbouncer/v0.3.0/mkbouncer.hpp")
file(DOWNLOAD https://raw.githubusercontent.com/measurement-kit/mkbouncer/v0.3.0/mkbouncer.hpp
"${CMAKE_BINARY_DIR}/.mkbuild/include/mkbouncer.hpp"
EXPECTED_HASH SHA256=7c0a810d58fdbc1ffdacb0eed442d31ebff819e49d1222b81619fe3c582a028c
TLS_VERIFY ON)
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include")
CHECK_INCLUDE_FILE_CXX("mkbouncer.hpp" MK_HAVE_HEADER_6320)
if(NOT ("${MK_HAVE_HEADER_6320}"))
message(FATAL_ERROR "cannot find: mkbouncer.hpp")
endif()
#
# mkcurl.hpp
#
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include"
RESULT_VARIABLE FAILURE_6659)
if("${FAILURE_6659}")
message(FATAL_ERROR "${FAILURE_6659}")
endif()
message(STATUS "download: https://raw.githubusercontent.com/measurement-kit/mkcurl/v0.12.0/mkcurl.hpp")
file(DOWNLOAD https://raw.githubusercontent.com/measurement-kit/mkcurl/v0.12.0/mkcurl.hpp
"${CMAKE_BINARY_DIR}/.mkbuild/include/mkcurl.hpp"
EXPECTED_HASH SHA256=cb58b85ccdf8d9f3b559ccab7d2f31cad4f8aba774e9953534e32373d415ec94
TLS_VERIFY ON)
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include")
CHECK_INCLUDE_FILE_CXX("mkcurl.hpp" MK_HAVE_HEADER_7189)
if(NOT ("${MK_HAVE_HEADER_7189}"))
message(FATAL_ERROR "cannot find: mkcurl.hpp")
endif()
#
# mkmock.hpp
#
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include"
RESULT_VARIABLE FAILURE_7522)
if("${FAILURE_7522}")
message(FATAL_ERROR "${FAILURE_7522}")
endif()
message(STATUS "download: https://raw.githubusercontent.com/measurement-kit/mkmock/v0.2.0/mkmock.hpp")
file(DOWNLOAD https://raw.githubusercontent.com/measurement-kit/mkmock/v0.2.0/mkmock.hpp
"${CMAKE_BINARY_DIR}/.mkbuild/include/mkmock.hpp"
EXPECTED_HASH SHA256=f07bc063a2e64484482f986501003e45ead653ea3f53fadbdb45c17a51d916d2
TLS_VERIFY ON)
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include")
CHECK_INCLUDE_FILE_CXX("mkmock.hpp" MK_HAVE_HEADER_8050)
if(NOT ("${MK_HAVE_HEADER_8050}"))
message(FATAL_ERROR "cannot find: mkmock.hpp")
endif()
#
# json.hpp
#
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include"
RESULT_VARIABLE FAILURE_8381)
if("${FAILURE_8381}")
message(FATAL_ERROR "${FAILURE_8381}")
endif()
message(STATUS "download: https://raw.githubusercontent.com/nlohmann/json/v3.6.1/single_include/nlohmann/json.hpp")
file(DOWNLOAD https://raw.githubusercontent.com/nlohmann/json/v3.6.1/single_include/nlohmann/json.hpp
"${CMAKE_BINARY_DIR}/.mkbuild/include/json.hpp"
EXPECTED_HASH SHA256=d2eeb25d2e95bffeb08ebb7704cdffd2e8fca7113eba9a0b38d60a5c391ea09a
TLS_VERIFY ON)
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include")
CHECK_INCLUDE_FILE_CXX("json.hpp" MK_HAVE_HEADER_8933)
if(NOT ("${MK_HAVE_HEADER_8933}"))
message(FATAL_ERROR "cannot find: json.hpp")
endif()
#
# Set restrictive compiler flags
#
macro(MKSetRestrictiveCompilerFlags)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR
("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Werror")
# https://www.owasp.org/index.php/C-Based_Toolchain_Hardening_Cheat_Sheet
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wall")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wextra")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wconversion")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wcast-align")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wformat=2")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wformat-security")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -fno-common")
# Some options are only supported by GCC when we're compiling C code:
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wmissing-prototypes")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wstrict-prototypes")
else()
set(MK_C_FLAGS "${MK_C_FLAGS} -Wmissing-prototypes")
set(MK_C_FLAGS "${MK_C_FLAGS} -Wstrict-prototypes")
endif()
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wmissing-declarations")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wstrict-overflow")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -Wtrampolines")
endif()
set(MK_CXX_FLAGS "${MK_CXX_FLAGS} -Woverloaded-virtual")
set(MK_CXX_FLAGS "${MK_CXX_FLAGS} -Wreorder")
set(MK_CXX_FLAGS "${MK_CXX_FLAGS} -Wsign-promo")
set(MK_CXX_FLAGS "${MK_CXX_FLAGS} -Wnon-virtual-dtor")
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} -fstack-protector-all")
if(NOT "${APPLE}" AND NOT "${MINGW}")
set(MK_LD_FLAGS "${MK_LD_FLAGS} -Wl,-z,noexecstack")
set(MK_LD_FLAGS "${MK_LD_FLAGS} -Wl,-z,now")
set(MK_LD_FLAGS "${MK_LD_FLAGS} -Wl,-z,relro")
set(MK_LD_FLAGS "${MK_LD_FLAGS} -Wl,-z,nodlopen")
set(MK_LD_FLAGS "${MK_LD_FLAGS} -Wl,-z,nodump")
elseif(("${MINGW}"))
set(MK_LD_FLAGS "${MK_LD_FLAGS} -static")
endif()
add_definitions(-D_FORTIFY_SOURCES=2)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# TODO(bassosimone): add support for /Wall and /analyze
set(MK_COMMON_FLAGS "${MK_COMMON_FLAGS} /WX /W4 /EHs")
set(MK_LD_FLAGS "${MK_LD_FLAGS} /WX")
else()
message(FATAL_ERROR "Compiler not supported: ${CMAKE_CXX_COMPILER_ID}")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MK_COMMON_FLAGS} ${MK_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MK_COMMON_FLAGS} ${MK_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MK_LD_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MK_LD_FLAGS}")
if("${WIN32}")
add_definitions(-D_WIN32_WINNT=0x0600) # for NI_NUMERICSERV and WSAPoll
endif()
endmacro()
MKSetRestrictiveCompilerFlags()
#
# Prepare for compiling targets
#
add_definitions(${CMAKE_REQUIRED_DEFINITIONS})
include_directories(${CMAKE_REQUIRED_INCLUDES})
#
# mkcollector
#
add_library(
mkcollector
mkcollector.cpp
)
target_link_libraries(
mkcollector
${CMAKE_REQUIRED_LIBRARIES}
)
#
# integration-tests
#
add_executable(
integration-tests
integration-tests.cpp
)
target_link_libraries(
integration-tests
mkcollector
${CMAKE_REQUIRED_LIBRARIES}
)
#
# tests
#
add_executable(
tests
tests.cpp
)
target_link_libraries(
tests
${CMAKE_REQUIRED_LIBRARIES}
)
#
# test: integration_tests
#
add_test(
NAME integration_tests COMMAND integration-tests
)
#
# test: mocked_tests
#
add_test(
NAME mocked_tests COMMAND tests
)