forked from usgs/neic-glass3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
378 lines (341 loc) · 13.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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# neic-glass3 overall CMake configuration file.
#
# This file contains the overall CMake configuration file that builds
# neic-glass3. This configuration follows the "CMake Superbuilds and Git
# Submodules" scheme to organize and orchestrate the build process, as
# described here: https://blog.kitware.com/cmake-superbuilds-git-submodules/
#
# Each local and remote submodule is configured as a separate CMake
# ExternalProject, either by defining a local directory where the submodule
# can be found, or a git repository address. Submodule dependencies are managed
# by ExternalProject's DEPENDS flags plus find_package lookups from within the
# submodule. Build options are passed down to submodules as appropriate.
cmake_minimum_required (VERSION 3.4)
set(CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake/)
# ----- PROJECT VERSION ----- #
include(${CMAKE_DIR}/version.cmake)
# ----- PROJECT ----- #
project (neic-glass3 VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
# ----- CMAKE INCLUDES ----- #
include(ExternalProject)
# ----- SETUP INSTALL LOCATIONS ----- #
set(INSTALL_LOCATION ${CMAKE_INSTALL_PREFIX})
# ----- PREPEND INSTALL LOCATIONS TO MODULE PATH ----- #
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${INSTALL_LOCATION}" )
# ----- OPTIONS ----- #
option(GENERATE_DOCUMENTATION "Create and install the HTML based API documentation" OFF)
option(RUN_TESTS "Create and run unit tests" ON)
option(BUILD_GLASS-APP "Build the glass application" ON)
option(BUILD_GLASS-BROKER-APP "Build the glass broker based application" OFF)
option(RUN_CPPCHECK "Run CPP Checks (requires cppcheck installed)" OFF)
option(RUN_CPPLINT "Run CPP Checks (requires cpplint and python installed)" OFF)
option(SUPPORT_COVERAGE "Instrument for Coverage" OFF)
option(RUN_COVERAGE "Run Coverage Report (requires lcov installed)" OFF)
option(GIT_CLONE_PUBLIC "Clone from public git URLs (https)" OFF)
# ----- EXTERNAL LIBRARIES ----- #
# Google Test
if (RUN_TESTS)
# ----- LOOK FOR GTEST ----- #
find_package(GTest)
# ----- DOWNLOAD GTEST IF NOT FOUND ----- #
if (NOT GTEST_FOUND)
set(GTEST_DEPEND "GTest")
MESSAGE(STATUS "Configuring to download GTest.")
if (GIT_CLONE_PUBLIC)
ExternalProject_Add(
GTest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.0
TIMEOUT 10
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
)
else()
ExternalProject_Add(
GTest
GIT_REPOSITORY [email protected]:google/googletest.git
GIT_TAG release-1.8.0
TIMEOUT 10
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
)
endif()
endif()
endif(RUN_TESTS)
# cpplint
if (RUN_CPPLINT)
set(PYTHON_PATH "/usr/bin/python" CACHE FILEPATH "Path to python")
set(CPPLINT_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/cpplint/cpplint.py" CACHE FILEPATH "Path to cpplint")
else()
set(PYTHON_PATH "")
set(CPPLINT_PATH "")
endif(RUN_CPPLINT)
# cppcheck
if (RUN_CPPCHECK)
set(CPPCHECK_PATH "/usr/local/bin/cppcheck" CACHE FILEPATH "Path to cppcheck")
else()
set(CPPCHECK_PATH "")
endif(RUN_CPPCHECK)
# Doxygen
if (BUILD_DOCUMENTATION)
# ----- LOOK FOR DOXYGEN ----- #
find_package(Doxygen)
# ----- DOWNLOAD DOXYGEN IF NOT FOUND ----- #
if(NOT DOXYGEN_FOUND)
MESSAGE(STATUS "Configuring to download Doxygen.")
if (GIT_CLONE_PUBLIC)
ExternalProject_Add(
Doxygen
GIT_REPOSITORY https://github.com/doxygen/doxygen.git
GIT_TAG Release_1_8_12
TIMEOUT 10
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
)
else()
ExternalProject_Add(
Doxygen
GIT_REPOSITORY [email protected]:doxygen/doxygen.git
GIT_TAG Release_1_8_12
TIMEOUT 10
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
)
endif()
set(DOXYGEN_DEPEND "Doxygen")
endif()
endif(BUILD_DOCUMENTATION)
# SuperEasyJSON
ExternalProject_Add(
SuperEasyJSON
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
SOURCE_DIR ${PROJECT_SOURCE_DIR}/lib/SuperEasyJSON/
UPDATE_COMMAND ""
)
if (BUILD_GLASS-APP OR BUILD_GLASS-BROKER-APP)
# rapidjson
set(RAPIDJSON_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson" CACHE PATH "Path to rapidjson")
# DetectionFormats
if (GIT_CLONE_PUBLIC)
ExternalProject_Add(DetectionFormats
GIT_REPOSITORY https://github.com/usgs/earthquake-detection-formats.git
GIT_TAG v0.9.10
TIMEOUT 10
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DRUN_TESTS=${RUN_TESTS}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
)
else()
ExternalProject_Add(DetectionFormats
GIT_REPOSITORY [email protected]:usgs/earthquake-detection-formats.git
GIT_TAG v0.9.10
TIMEOUT 10
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DRUN_TESTS=${RUN_TESTS}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
)
endif()
endif()
if (BUILD_GLASS-BROKER-APP)
# rdkafka
set(LIBRDKAFKA_PATH
"${CMAKE_CURRENT_LIST_DIR}/lib/rdkafka/"
CACHE PATH "Path to rdkafka")
set(LIBRDKAFKA_C_LIB
"${CMAKE_CURRENT_LIST_DIR}/lib/rdkafka/src/${CMAKE_SHARED_LIBRARY_PREFIX}rdkafka${CMAKE_SHARED_LIBRARY_SUFFIX}"
CACHE FILEPATH "Path to the rdkafka c library")
set(LIBRDKAFKA_CPP_LIB
"${CMAKE_CURRENT_LIST_DIR}/lib/rdkafka/src_cpp/${CMAKE_SHARED_LIBRARY_PREFIX}rdkafka++${CMAKE_SHARED_LIBRARY_SUFFIX}"
CACHE FILEPATH "Path to the rdkafka cpp library")
# HazdevBroker
if (GIT_CLONE_PUBLIC)
ExternalProject_Add(HazdevBroker
GIT_REPOSITORY https://github.com/usgs/hazdev-broker.git
GIT_TAG v0.2.2
TIMEOUT 10
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DLIBRDKAFKA_PATH=${LIBRDKAFKA_PATH}
-DLIBRDKAFKA_C_LIB=${LIBRDKAFKA_C_LIB}
-DLIBRDKAFKA_CPP_LIB=${LIBRDKAFKA_CPP_LIB}
)
else()
ExternalProject_Add(HazdevBroker
GIT_REPOSITORY [email protected]:usgs/hazdev-broker.git
GIT_TAG v0.2.2
TIMEOUT 10
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DLIBRDKAFKA_PATH=${LIBRDKAFKA_PATH}
-DLIBRDKAFKA_C_LIB=${LIBRDKAFKA_C_LIB}
-DLIBRDKAFKA_CPP_LIB=${LIBRDKAFKA_CPP_LIB}
)
endif()
endif()
# ----- PROJECT LIBRARIES ----- #
# util
ExternalProject_Add(
util
SOURCE_DIR ${PROJECT_SOURCE_DIR}/util/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DRUN_TESTS=${RUN_TESTS}
-DRUN_CPPCHECK=${RUN_CPPCHECK}
-DRUN_CPPLINT=${RUN_CPPLINT}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
-DRUN_COVERAGE=${RUN_COVERAGE}
-DPYTHON_PATH=${PYTHON_PATH}
-DCPPLINT_PATH=${CPPLINT_PATH}
-DCPPCHECK_PATH=${CPPCHECK_PATH}
DEPENDS SuperEasyJSON ${DOXYGEN_DEPEND} ${GTEST_DEPEND}
UPDATE_COMMAND ""
)
# glasscore
ExternalProject_Add(
glasscore
SOURCE_DIR ${PROJECT_SOURCE_DIR}/glasscore/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DRUN_TESTS=${RUN_TESTS}
-DRUN_CPPCHECK=${RUN_CPPCHECK}
-DRUN_CPPLINT=${RUN_CPPLINT}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
-DRUN_COVERAGE=${RUN_COVERAGE}
-DPYTHON_PATH=${PYTHON_PATH}
-DCPPLINT_PATH=${CPPLINT_PATH}
-DCPPCHECK_PATH=${CPPCHECK_PATH}
DEPENDS SuperEasyJSON util ${DOXYGEN_DEPEND} ${GTEST_DEPEND}
UPDATE_COMMAND ""
)
if (BUILD_GLASS-APP OR BUILD_GLASS-BROKER-APP)
# parse
ExternalProject_Add(
parse
SOURCE_DIR ${PROJECT_SOURCE_DIR}/parse/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DRUN_TESTS=${RUN_TESTS}
-DRUN_CPPCHECK=${RUN_CPPCHECK}
-DRUN_CPPLINT=${RUN_CPPLINT}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
-DRUN_COVERAGE=${RUN_COVERAGE}
-DPYTHON_PATH=${PYTHON_PATH}
-DCPPLINT_PATH=${CPPLINT_PATH}
-DCPPCHECK_PATH=${CPPCHECK_PATH}
DEPENDS SuperEasyJSON util DetectionFormats ${DOXYGEN_DEPEND} ${GTEST_DEPEND}
UPDATE_COMMAND ""
)
# process
ExternalProject_Add(
process
SOURCE_DIR ${PROJECT_SOURCE_DIR}/process/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DRUN_CPPCHECK=${RUN_CPPCHECK}
-DRUN_CPPLINT=${RUN_CPPLINT}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
-DPYTHON_PATH=${PYTHON_PATH}
-DCPPLINT_PATH=${CPPLINT_PATH}
-DCPPCHECK_PATH=${CPPCHECK_PATH}
DEPENDS SuperEasyJSON glasscore util ${DOXYGEN_DEPEND}
UPDATE_COMMAND ""
)
# output
ExternalProject_Add(
output
SOURCE_DIR ${PROJECT_SOURCE_DIR}/output/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DRUN_TESTS=${RUN_TESTS}
-DRUN_CPPCHECK=${RUN_CPPCHECK}
-DRUN_CPPLINT=${RUN_CPPLINT}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
-DRUN_COVERAGE=${RUN_COVERAGE}
-DPYTHON_PATH=${PYTHON_PATH}
-DCPPLINT_PATH=${CPPLINT_PATH}
-DCPPCHECK_PATH=${CPPCHECK_PATH}
DEPENDS SuperEasyJSON util DetectionFormats parse ${DOXYGEN_DEPEND} ${GTEST_DEPEND}
UPDATE_COMMAND ""
)
# input
ExternalProject_Add(
input
SOURCE_DIR ${PROJECT_SOURCE_DIR}/input/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DRUN_TESTS=${RUN_TESTS}
-DRUN_CPPCHECK=${RUN_CPPCHECK}
-DRUN_CPPLINT=${RUN_CPPLINT}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
-DRUN_COVERAGE=${RUN_COVERAGE}
-DPYTHON_PATH=${PYTHON_PATH}
-DCPPLINT_PATH=${CPPLINT_PATH}
-DCPPCHECK_PATH=${CPPCHECK_PATH}
DEPENDS SuperEasyJSON util DetectionFormats parse ${DOXYGEN_DEPEND} ${GTEST_DEPEND}
UPDATE_COMMAND ""
)
endif()
# ----- PROJECT APPLICATIONS ----- #
if (BUILD_GLASS-APP)
# glass-app
ExternalProject_Add(
glass-app
SOURCE_DIR ${PROJECT_SOURCE_DIR}/glass-app/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DRUN_TESTS=${RUN_TESTS}
-DRUN_CPPCHECK=${RUN_CPPCHECK}
-DRUN_CPPLINT=${RUN_CPPLINT}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
-DRUN_COVERAGE=${RUN_COVERAGE}
-DPYTHON_PATH=${PYTHON_PATH}
-DCPPLINT_PATH=${CPPLINT_PATH}
-DCPPCHECK_PATH=${CPPCHECK_PATH}
DEPENDS SuperEasyJSON util DetectionFormats parse glasscore process output input ${DOXYGEN_DEPEND} ${GTEST_DEPEND}
UPDATE_COMMAND ""
)
endif()
if (BUILD_GLASS-BROKER-APP)
# glass-broker-app
ExternalProject_Add(
glass-broker-app
SOURCE_DIR ${PROJECT_SOURCE_DIR}/glass-broker-app/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DRAPIDJSON_PATH=${RAPIDJSON_PATH}
-DLIBRDKAFKA_PATH=${LIBRDKAFKA_PATH}
-DLIBRDKAFKA_C_LIB=${LIBRDKAFKA_C_LIB}
-DLIBRDKAFKA_CPP_LIB=${LIBRDKAFKA_CPP_LIB}
-DRUN_CPPCHECK=${RUN_CPPCHECK}
-DRUN_CPPLINT=${RUN_CPPLINT}
-DSUPPORT_COVERAGE=${SUPPORT_COVERAGE}
-DPYTHON_PATH=${PYTHON_PATH}
-DCPPLINT_PATH=${CPPLINT_PATH}
-DCPPCHECK_PATH=${CPPCHECK_PATH}
DEPENDS SuperEasyJSON util DetectionFormats parse glasscore process output input HazdevBroker ${DOXYGEN_DEPEND} ${GTEST_DEPEND}
UPDATE_COMMAND ""
)
endif()
# ----- GENERATE DOCUMENTATION ----- #
set(DOC_DIRS "${PROJECT_SOURCE_DIR}/util/ ${PROJECT_SOURCE_DIR}/glasscore/ ${PROJECT_SOURCE_DIR}/parse/ ${PROJECT_SOURCE_DIR}/input/ ${PROJECT_SOURCE_DIR}/output/ ${PROJECT_SOURCE_DIR}/process/ ${PROJECT_SOURCE_DIR}/glass-app/ ${PROJECT_SOURCE_DIR}/glass-broker-app/ ${PROJECT_SOURCE_DIR}/gen-travel-times-app/")
include(${CMAKE_DIR}/documentation.cmake)