|
1 | 1 | cmake_minimum_required(VERSION 3.10)
|
2 |
| -project(muondetector-cluster LANGUAGES CXX C) |
| 2 | +project(detector-network-processor LANGUAGES CXX C) |
3 | 3 |
|
4 | 4 | string(TIMESTAMP PROJECT_DATE_STRING "%b %d, %Y")
|
5 | 5 |
|
6 |
| -option(CLUSTER_BUILD_TIDY "run clang-tidy when building the project" OFF) |
7 |
| -option(CLUSTER_FORMAT "run clang-format when building the project" ON) |
| 6 | +option(PROCESSOR_DISABLE_SSL "build the code so the rest service doesn't use SSL" |
| 7 | + OFF) |
| 8 | +option(PROCESSOR_BUILD_AGGREGATION "along with the default application, also build the aggregation executable." |
| 9 | + OFF) |
8 | 10 |
|
9 | 11 | set(PROJECT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
10 | 12 | set(PROJECT_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
11 | 13 | set(PROJECT_CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/config")
|
12 | 14 |
|
13 |
| -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin") |
| 15 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/bin") |
14 | 16 | include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake")
|
15 | 17 |
|
16 |
| - |
17 |
| -if(${CLUSTER_BUILD_TIDY}) |
18 |
| - set(CMAKE_CXX_CLANG_TIDY |
19 |
| - clang-tidy; |
20 |
| - -header-filter=^global; |
21 |
| - -checks=-*,bugprone-*,performace-*,readability-*,-readability-magic-numbers,modernize-*,hicpp-*,clang-analyzer-*; |
22 |
| - -fix; |
23 |
| - ) |
24 |
| -endif(${CLUSTER_BUILD_TIDY}) |
| 18 | +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/files.cmake") |
25 | 19 |
|
26 | 20 | set(CMAKE_CXX_STANDARD 17)
|
27 | 21 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
28 | 22 |
|
| 23 | +add_compile_options(-Wall -Wextra -Wshadow -Wpedantic -Werror -O3) |
29 | 24 |
|
30 |
| -add_compile_options( |
31 |
| - -Wall |
32 |
| - -Wextra |
33 |
| - -Wshadow |
34 |
| - -Wpedantic |
35 |
| - -Werror |
36 |
| - -O3 |
37 |
| - ) |
38 |
| - |
| 25 | +if(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) |
| 26 | +add_compile_options(-fsanitize=address,undefined) |
| 27 | +add_link_options(-fsanitize=address,undefined) |
| 28 | +endif() |
39 | 29 |
|
40 | 30 |
|
41 | 31 | find_library(MOSQUITTO mosquitto REQUIRED)
|
42 |
| -find_library(CRYPTOPP crypto++ REQUIRED) |
43 |
| -find_library(CURL curl REQUIRED) |
44 | 32 | find_library(SASL2 sasl2 REQUIRED)
|
45 | 33 | find_library(LDAP ldap REQUIRED)
|
46 |
| -find_library(RESTBED restbed REQUIRED) |
47 |
| - |
48 |
| -find_library(STD_CPP_FS stdc++fs /usr/lib/gcc/x86_64-linux-gnu/8/) |
49 |
| - |
| 34 | +find_library(DL dl REQUIRED) |
50 | 35 |
|
| 36 | +find_package( |
| 37 | + Boost 1.71 |
| 38 | + COMPONENTS system program_options |
| 39 | + REQUIRED) |
51 | 40 |
|
52 |
| - |
53 |
| -set(CLUSTER_SOURCE_FILES |
54 |
| - "${PROJECT_SRC_DIR}/coincidencefilter.cpp" |
55 |
| - "${PROJECT_SRC_DIR}/detectortracker.cpp" |
56 |
| - "${PROJECT_SRC_DIR}/detector.cpp" |
57 |
| - "${PROJECT_SRC_DIR}/triggerhandler.cpp" |
58 |
| - |
59 |
| - "${PROJECT_SRC_DIR}/link/mqtt.cpp" |
60 |
| - "${PROJECT_SRC_DIR}/link/database.cpp" |
61 |
| - |
62 |
| - "${PROJECT_SRC_DIR}/messages/event.cpp" |
63 |
| - "${PROJECT_SRC_DIR}/messages/detectorlog.cpp" |
64 |
| - "${PROJECT_SRC_DIR}/messages/detectorinfo.cpp" |
65 |
| - "${PROJECT_SRC_DIR}/messages/detectorsummary.cpp" |
66 |
| - "${PROJECT_SRC_DIR}/messages/clusterlog.cpp" |
67 |
| - |
68 |
| - "${PROJECT_SRC_DIR}/utility/coincidence.cpp" |
69 |
| - "${PROJECT_SRC_DIR}/utility/eventconstructor.cpp" |
70 |
| - "${PROJECT_SRC_DIR}/utility/threadrunner.cpp" |
71 |
| - "${PROJECT_SRC_DIR}/utility/log.cpp" |
72 |
| - "${PROJECT_SRC_DIR}/utility/utility.cpp" |
73 |
| - "${PROJECT_SRC_DIR}/utility/geohash.cpp" |
74 |
| - "${PROJECT_SRC_DIR}/utility/parameters.cpp" |
75 |
| - "${PROJECT_SRC_DIR}/utility/configuration.cpp" |
76 |
| - "${PROJECT_SRC_DIR}/utility/resourcetracker.cpp" |
77 |
| - |
78 |
| - "${PROJECT_SRC_DIR}/supervision/state.cpp" |
79 |
| - "${PROJECT_SRC_DIR}/supervision/timebase.cpp" |
80 |
| - ) |
81 |
| - |
82 |
| -set(CLUSTER_HEADER_FILES |
83 |
| - "${PROJECT_HEADER_DIR}/coincidencefilter.h" |
84 |
| - "${PROJECT_HEADER_DIR}/detectortracker.h" |
85 |
| - "${PROJECT_HEADER_DIR}/detector.h" |
86 |
| - "${PROJECT_HEADER_DIR}/triggerhandler.h" |
87 |
| - "${PROJECT_HEADER_DIR}/pipeline.h" |
88 |
| - |
89 |
| - "${PROJECT_HEADER_DIR}/link/database.h" |
90 |
| - "${PROJECT_HEADER_DIR}/link/mqtt.h" |
91 |
| - |
92 |
| - "${PROJECT_HEADER_DIR}/sink/base.h" |
93 |
| - "${PROJECT_HEADER_DIR}/sink/database.h" |
94 |
| - "${PROJECT_HEADER_DIR}/sink/mqtt.h" |
95 |
| - "${PROJECT_HEADER_DIR}/sink/ascii.h" |
96 |
| - |
97 |
| - "${PROJECT_HEADER_DIR}/source/base.h" |
98 |
| - "${PROJECT_HEADER_DIR}/source/mqtt.h" |
99 |
| - |
100 |
| - "${PROJECT_HEADER_DIR}/messages/event.h" |
101 |
| - "${PROJECT_HEADER_DIR}/messages/detectorlog.h" |
102 |
| - "${PROJECT_HEADER_DIR}/messages/detectorinfo.h" |
103 |
| - "${PROJECT_HEADER_DIR}/messages/detectorsummary.h" |
104 |
| - "${PROJECT_HEADER_DIR}/messages/clusterlog.h" |
105 |
| - "${PROJECT_HEADER_DIR}/messages/userinfo.h" |
106 |
| - "${PROJECT_HEADER_DIR}/messages/trigger.h" |
107 |
| - |
108 |
| - "${PROJECT_HEADER_DIR}/utility/threadrunner.h" |
109 |
| - "${PROJECT_HEADER_DIR}/utility/coincidence.h" |
110 |
| - "${PROJECT_HEADER_DIR}/utility/criterion.h" |
111 |
| - "${PROJECT_HEADER_DIR}/utility/log.h" |
112 |
| - "${PROJECT_HEADER_DIR}/utility/utility.h" |
113 |
| - "${PROJECT_HEADER_DIR}/utility/geohash.h" |
114 |
| - "${PROJECT_HEADER_DIR}/utility/eventconstructor.h" |
115 |
| - "${PROJECT_HEADER_DIR}/utility/parameters.h" |
116 |
| - "${PROJECT_HEADER_DIR}/utility/configuration.h" |
117 |
| - "${PROJECT_HEADER_DIR}/utility/resourcetracker.h" |
118 |
| - |
119 |
| - "${PROJECT_HEADER_DIR}/supervision/state.h" |
120 |
| - "${PROJECT_HEADER_DIR}/supervision/timebase.h" |
121 |
| - ) |
122 |
| - |
123 |
| -configure_file( |
124 |
| - "${PROJECT_CONFIG_DIR}/muondetector-cluster.1" |
125 |
| - "${CMAKE_CURRENT_BINARY_DIR}/muondetector-cluster.1" |
126 |
| - ) |
127 |
| - |
128 |
| -configure_file( |
129 |
| - "${PROJECT_CONFIG_DIR}/config.h" |
130 |
| - "${CMAKE_CURRENT_BINARY_DIR}/defaults.h" |
131 |
| - ) |
132 |
| - |
133 |
| -add_library(source-files OBJECT ${CLUSTER_SOURCE_FILES} ${CLUSTER_HEADER_FILES}) |
134 |
| -target_include_directories(source-files PUBLIC |
135 |
| - ${PROJECT_HEADER_DIR} |
136 |
| - ${CMAKE_CURRENT_BINARY_DIR} |
137 |
| - ) |
138 |
| - |
139 |
| -add_executable(muondetector-cluster "${PROJECT_SRC_DIR}/main.cpp") |
140 |
| - |
141 |
| -if (CMAKE_BUILD_TYPE STREQUAL Release) |
142 |
| - add_custom_command(TARGET muondetector-cluster POST_BUILD |
143 |
| - COMMAND ${CMAKE_STRIP} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/muondetector-cluster") |
144 |
| -endif () |
145 |
| -target_include_directories(muondetector-cluster PUBLIC |
146 |
| - ${PROJECT_HEADER_DIR} |
147 |
| - ${CMAKE_CURRENT_BINARY_DIR} |
148 |
| - ) |
149 |
| - |
150 |
| -if (NOT STD_CPP_FS) |
151 |
| -target_link_libraries(muondetector-cluster |
152 |
| - crypto++ |
153 |
| - mosquitto |
154 |
| - source-files |
155 |
| - pthread |
156 |
| - curl |
157 |
| - restbed |
158 |
| - sasl2 |
159 |
| - ldap |
160 |
| - ) |
161 |
| -else() |
162 |
| -target_link_libraries(muondetector-cluster |
163 |
| - crypto++ |
| 41 | +set(PROJECT_INCLUDE_LIBS |
164 | 42 | mosquitto
|
165 |
| - source-files |
166 | 43 | pthread
|
167 |
| - curl |
168 |
| - restbed |
169 | 44 | sasl2
|
170 | 45 | ldap
|
171 |
| - stdc++fs |
172 |
| - ) |
| 46 | + boost_system |
| 47 | + boost_program_options |
| 48 | + ssl |
| 49 | + crypto |
| 50 | + dl) |
| 51 | + |
| 52 | +# +++ necessary for compatability with older compilers |
| 53 | +find_library(STD_CPP_FS stdc++fs /usr/lib/gcc/x86_64-linux-gnu/8/) |
| 54 | + |
| 55 | +if(STD_CPP_FS) |
| 56 | + set(PROJECT_INCLUDE_LIBS ${PROJECT_INCLUDE_LIBS} stdc++fs) |
| 57 | +endif() |
| 58 | +# --- necessary for compatability with older compilers |
| 59 | + |
| 60 | +configure_file("${PROJECT_CONFIG_DIR}/detector-network-processor.1" |
| 61 | + "${CMAKE_CURRENT_BINARY_DIR}/detector-network-processor.1") |
| 62 | + |
| 63 | +configure_file("${PROJECT_CONFIG_DIR}/config.h" |
| 64 | + "${CMAKE_CURRENT_BINARY_DIR}/defaults.h") |
| 65 | + |
| 66 | +if (PROCESSOR_BUILD_AGGREGATION) |
| 67 | +add_executable(aggregation "${PROJECT_SRC_DIR}/aggregation.cpp") |
173 | 68 | endif()
|
174 | 69 |
|
| 70 | +add_executable( |
| 71 | + detector-network-processor ${PROJECT_SOURCE_FILES} ${PROJECT_HEADER_FILES}) |
| 72 | + |
| 73 | +target_include_directories( |
| 74 | + detector-network-processor PUBLIC ${PROJECT_HEADER_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
| 75 | + |
| 76 | +target_link_libraries(detector-network-processor ${PROJECT_INCLUDE_LIBS}) |
| 77 | + |
| 78 | +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/packaging.cmake") |
175 | 79 |
|
176 |
| -include(GNUInstallDirs) |
177 |
| - |
178 |
| -add_custom_target(changelog-cluster ALL COMMAND gzip -cn9 "${PROJECT_CONFIG_DIR}/changelog" > "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz") |
179 |
| -add_custom_target(manpage-cluster ALL COMMAND gzip -cn9 "${CMAKE_CURRENT_BINARY_DIR}/muondetector-cluster.1" > "${CMAKE_CURRENT_BINARY_DIR}/muondetector-cluster.1.gz") |
180 |
| - |
181 |
| -if(${CLUSTER_FORMAT}) |
182 |
| -add_custom_target(clangformat ALL COMMAND clang-format -style=WebKit -i ${CLUSTER_SOURCE_FILES} ${CLUSTER_HEADER_FILES} "${PROJECT_SRC_DIR}/main.cpp") |
183 |
| -endif(${CLUSTER_FORMAT}) |
184 |
| - |
185 |
| -install(TARGETS muondetector-cluster DESTINATION bin COMPONENT cluster) |
186 |
| -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz" DESTINATION "${CMAKE_INSTALL_DOCDIR}" COMPONENT cluster) |
187 |
| -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/muondetector-cluster.1.gz" DESTINATION "share/man/man1/" COMPONENT cluster) |
188 |
| -install(FILES "${PROJECT_CONFIG_DIR}/copyright" DESTINATION "${CMAKE_INSTALL_DOCDIR}" COMPONENT cluster) |
189 |
| -install(FILES "${PROJECT_CONFIG_DIR}/muondetector-cluster.service" DESTINATION "/lib/systemd/system" COMPONENT cluster) |
190 |
| -install(FILES "${PROJECT_CONFIG_DIR}/muondetector-cluster.cfg" DESTINATION "/etc/muondetector/" COMPONENT cluster) |
191 |
| -install(FILES "${PROJECT_CONFIG_DIR}/muondetector-cluster-credentials" DESTINATION "share/muondetector/" COMPONENT cluster) |
192 |
| - |
193 |
| - |
194 |
| - |
195 |
| -set(CPACK_GENERATOR "DEB") |
196 |
| -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) |
197 |
| -set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_CONFIG_DIR}/license") |
198 |
| -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_CONFIG_DIR}/postinst;${PROJECT_CONFIG_DIR}/conffiles") |
199 |
| -set(CPACK_PACKAGE_VENDOR "MuonPi.org") |
200 |
| -set(CPACK_DEBIAN_PACKAGE_SECTION "net") |
201 |
| -set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/MuonPi/muondetector-cluster") |
202 |
| -set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") |
203 |
| -set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") |
204 |
| -set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") |
205 |
| -set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") |
206 |
| -set(CPACK_DEBIAN_PACKAGE_DESCRIPTION " Daemon which calculates coincidences for incoming events |
207 |
| - It subscribes to a mqtt topic to collect the incoming event messages and keep |
208 |
| - trace of individual event sources. |
209 |
| - With these messages it calculates coincidences and depending on the context |
210 |
| - publishes them to another mqtt topic or writes them to a database. |
211 |
| - It is licensed under the GNU Lesser General Public License version 3 (LGPL v3).") |
212 |
| -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "MuonPi <developer@muonpi.org>") |
213 |
| -set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../packages/") |
214 |
| - |
215 |
| -include(CPack) |
| 80 | +add_custom_target(clangformat COMMAND clang-format -style=WebKit -i ${PROJECT_SOURCE_FILES} ${PROJECT_HEADER_FILES} "${PROJECT_SRC_DIR}/aggregation.cpp") |
0 commit comments