-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
265 lines (205 loc) · 7.72 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
cmake_minimum_required(VERSION 2.8)
project(EDGEMW)
# command line
option(CONFIG_USE_CLANG "test with clang / clang++" off)
option(CONFIG_RELEASE off)
option(CONFIG_SHAREDLIB off)
set(OS_FLAGS "-DOS_LINUX")
if (CONFIG_USE_CLANG)
message("using clang..")
set(CMAKE_C_COMPILER "clang")
set(CMAKE_C_FLAGS "-Wall -Weverything ${OS_FLAGS} -DCONFIG_CRYPTO_LIB_OPENSSL")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -Weverything ${OS_FLAGS} -DCONFIG_CRYPTO_LIB_OPENSSL")
else()
message("using gcc..")
set(CMAKE_C_COMPILER "gcc")
if (CONFIG_RELEASE)
set(CMAKE_C_FLAGS "-Os -Wall -Werror -Wextra -Wno-unused-parameter -Wshadow -fPIE -fPIC -D_FORTIFY_SOURCE=2 -DCONFIG_EDGEOS_DETAILED_ERRORS -DWC_NO_HARDEN -DCONFIG_CRYPTO_LIB_OPENSSL ${OS_FLAGS}")
set(CMAKE_CXX_FLAGS "-Os -Wall -Wextra -Werror -Wno-unused-parameter -Wshadow -fPIC -fPIE -std=c++11 -DCONFIG_EDGEOS_DETAILED_ERRORS -DWC_NO_HARDEN -DCONFIG_CRYPTO_LIB_OPENSSL ${OS_FLAGS}")
else()
set(CMAKE_C_FLAGS "-O0 -ggdb -g -Wall -Werror -Wextra -Wno-unused-parameter -Wshadow -fPIE -fPIC -fprofile-arcs -ftest-coverage -D_FORTIFY_SOURCE=2 -DCONFIG_EDGEOS_DETAILED_ERRORS -DWC_NO_HARDEN -DCONFIG_CRYPTO_LIB_OPENSSL -pg ${OS_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-unused-parameter -Wshadow -fPIC -fPIE -std=c++11 -pg -fprofile-arcs -ftest-coverage -pg -std=c++11 -DCONFIG_EDGEOS_DETAILED_ERRORS -DWC_NO_HARDEN -DCONFIG_CRYPTO_LIB_OPENSSL ${OS_FLAGS}")
endif()
set(CMAKE_CXX_COMPILER "g++")
endif()
SET(ALG_SOURCES
lib/algorithms/list.c
lib/algorithms/dlist.c
lib/algorithms/static_list.c
lib/algorithms/stack.c
lib/algorithms/queue.c
lib/algorithms/hashtbl.c)
SET(LINUX_SPEC_SOURCES
lib/linux/net/socket.c
lib/linux/shmem/shmem.c
lib/linux/crypto/prng.c
lib/linux/file_system/fsapi.c
lib/linux/net/TcpServer.cpp
lib/linux/net/ClientMgr.cpp
lib/linux/sched/sched.c
lib/linux/net/sysioctl.c
lib/linux/pthreads/pthreads.c
lib/linux/net/ds/generated/dist_sdp.pb-c.c
lib/linux/date_time/date_time.c
lib/linux/process/process.c
lib/linux/fifo/fifo.c
lib/linux/msgqueue/msg_queue.c
lib/linux/monitoring/monitor.c)
SET(UTIL_SOURCES
lib/util/csvclass.cpp
lib/util/tokenparse.c
lib/util/TokParse.cpp
lib/util/conv.c
lib/util/hex.c)
SET(CRYPTO_SOURCES)
#lib/crypto/crypto.c)
SET(GPSLIB_SOURCES
lib/gpslib/src/nmea/nmea_parser.cpp)
SET(CONFIG_PARSER_SOURCES
lib/config/config_parser.c
lib/config/config_parser.cpp)
set(SOURCES
lib/evtloop/evtloop.c
${ALG_SOURCES}
lib/logger/edgeos_logger.c
${LINUX_SPEC_SOURCES}
${UTIL_SOURCES}
lib/logger/logger.c
services/distcom/distcomm_pub.c
services/distcom/dist_sdp.c
${GPSLIB_SOURCES}
${CRYPTO_SOURCES}
${CONFIG_PARSER_SOURCES})
set(LIB_TEST_SOURCES
tests/test_socket.c)
set(DISTCOMM_SOURCES
services/distcom/master.c)
set(DIST_TEST_SOURCES
tests/test_distcom.c)
set(NMEA_TEST_SOURCES
lib/gpslib/src/tests/unit_tests/unit_core.cpp)
set(TCPSERVER_TEST_SOURCES
tests/test_TcpServer.cpp)
set(TEST_CASES_SOURCES
tests/test_framework.cpp
tests/test_fsapi.cpp
tests/test_tokparse.cpp
tests/test_list.c
tests/test_evtloop.cpp
tests/test_prng.c
tests/test_sysioctl.c
tests/test_pthread.c
#tests/test_crypto.c
tests/test_sched.c
tests/test_config_parser.cpp
tests/test_dlist.c
tests/test_static_list.c
tests/test_stack.c
tests/test_queue.c
tests/test_fifo.c
#tests/test_ssl.c
tests/test_hashtbl.c
tests/test_msg_queue.cpp
tests/test_monitor.cpp
tests/test_raw.c)
set(TRANSFER_TEST_SOURCES
tests/transfer_test.c)
set(DS_SOURCES
lib/linux/net/ds/controller.c)
SET(DS_SAMPLE_SOURCES
lib/linux/net/ds/sample.c)
include_directories(
lib/evtloop/
lib/linux/net/
remoteLog/
lib/algorithms/
lib/logger/
lib/linux/net/
lib/linux/shmem/
lib/linux/transport/
lib/linux/crypto/
lib/incl/
lib/linux/fifo/
services/distcom/
lib/
lib/gpslib/src/nmea/
lib/util/
lib/linux/file_system/
lib/linux/sched/
lib/linux/pthreads/
lib/linux/net/ds/
lib/linux/net/ds/generated/
services/supervisor/
services/ota/
lib/crypto/
lib/linux/msgqueue/
lib/config/
lib/linux/date_time/
lib/linux/process/
lib/linux/monitoring/
services/cli/
services/cli/library/)
SET(SUPERVISOR_SOURCES
services/supervisor/supervisor.c)
SET(TEST_SUPERVISOR_SOURCES
services/supervisor/test_supervisor.c)
SET(OTA_SOURCES
services/ota/ota.c)
SET(CLI_SERVICE_SOURCES
services/cli/backend.c)
SET(CLI_CLIENT_SOURCES
services/cli/commands.c
services/cli/database.c
services/cli/library/show_callback.c
services/cli/rpc.c)
set(ASN1_COMPILER_SOURCES
lib/asn1/compiler/core.cpp
lib/asn1/compiler/types.c)
add_library(EdgeOS STATIC ${SOURCES})
if (CONFIG_SHAREDLIB)
add_library(EdgeOSShared SHARED ${SOURCES})
target_link_libraries(EdgeOSShared pthread rt gcov protobuf-c crypto ssl)
endif()
target_link_libraries(EdgeOS pthread rt gcov protobuf-c crypto ssl)
add_executable(asn1compiler ${ASN1_COMPILER_SOURCES})
target_link_libraries(asn1compiler rt)
add_executable(EdgeOSLogger services/logsrv/edgeos_logsrv.cpp)
target_link_libraries(EdgeOSLogger pthread EdgeOS gcov rt)
add_executable(loggerTest services/logsrv/tests/logsrv_test.c)
target_link_libraries(loggerTest pthread EdgeOS gcov)
add_executable(distCommMaster ${DISTCOMM_SOURCES})
target_link_libraries(distCommMaster pthread EdgeOS gcov)
add_executable(EOSTest ${LIB_TEST_SOURCES})
target_link_libraries(EOSTest pthread EdgeOS gcov)
add_executable(DistTest ${DIST_TEST_SOURCES})
target_link_libraries(DistTest pthread EdgeOS gcov)
add_executable(nmeaTest ${NMEA_TEST_SOURCES})
target_link_libraries(nmeaTest pthread EdgeOS gcov)
add_executable(TcpServerTest ${TCPSERVER_TEST_SOURCES})
target_link_libraries(TcpServerTest pthread EdgeOS gcov)
add_executable(TestExecutor ${TEST_CASES_SOURCES})
target_link_libraries(TestExecutor pthread EdgeOS gcov crypto ssl)
add_executable(TransferTest ${TRANSFER_TEST_SOURCES})
target_link_libraries(TransferTest pthread EdgeOS gcov)
add_executable(DsController ${DS_SOURCES})
target_link_libraries(DsController pthread EdgeOS gcov protobuf-c)
add_executable(DsSample ${DS_SAMPLE_SOURCES})
target_link_libraries(DsSample pthread EdgeOS gcov protobuf-c)
add_executable(EdgeOSSupervisor ${SUPERVISOR_SOURCES})
target_link_libraries(EdgeOSSupervisor pthread EdgeOS gcov protobuf-c)
add_executable(SupervisorTest ${TEST_SUPERVISOR_SOURCES})
target_link_libraries(SupervisorTest pthread EdgeOS gcov protobuf-c crypto)
add_executable(EdgeOSOTA ${OTA_SOURCES})
target_link_libraries(EdgeOSOTA pthread EdgeOS gcov protobuf-c)
add_executable(EdgeOSCLId ${CLI_SERVICE_SOURCES})
target_link_libraries(EdgeOSCLId pthread EdgeOS gcov protobuf-c)
add_executable(EdgeOSCLI ${CLI_CLIENT_SOURCES})
target_link_libraries(EdgeOSCLI pthread EdgeOS gcov protobuf-c)
## building sample applications
SET(SAMPLE_UDP_CLIENT_SOURCES examples/udp_client.c)
SET(SAMPLE_UDP_SERVER_SOURCES examples/udp_server.c)
add_executable(sample_udp_client ${SAMPLE_UDP_CLIENT_SOURCES})
target_link_libraries(sample_udp_client pthread EdgeOS gcov protobuf-c)
add_executable(sample_udp_server ${SAMPLE_UDP_SERVER_SOURCES})
target_link_libraries(sample_udp_server pthread EdgeOS gcov protobuf-c)