-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
325 lines (293 loc) · 10.7 KB
/
CMakeLists.txt
File metadata and controls
325 lines (293 loc) · 10.7 KB
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
# Honor visibility properties for all target types
cmake_policy(SET CMP0063 NEW)
include_directories( . ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/public ${CMAKE_CURRENT_SOURCE_DIR}/include/public ${CMAKE_CURRENT_SOURCE_DIR}/include/mat ${CMAKE_CURRENT_SOURCE_DIR}/pal ${CMAKE_CURRENT_SOURCE_DIR}/utils ${CMAKE_CURRENT_SOURCE_DIR}/modules/exp ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard ${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/Reachability ${CMAKE_CURRENT_SOURCE_DIR}/modules/cds ${CMAKE_CURRENT_SOURCE_DIR}/modules/signals ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer /usr/local/include )
set(SRCS decorators/BaseDecorator.cpp
packager/BondSplicer.cpp
packager/Packager.cpp
callbacks/DebugSource.cpp
bond/BondSerializer.cpp
filter/EventFilterCollection.cpp
tpm/TransmitProfiles.cpp
tpm/TransmissionPolicyManager.cpp
tpm/DeviceStateHandler.cpp
system/EventProperty.cpp
system/TelemetrySystem.cpp
system/EventProperties.cpp
compression/HttpDeflateCompression.cpp
api/AllowedLevelsCollection.cpp
api/LogManager.cpp
api/ContextFieldsProvider.cpp
api/LogManagerImpl.cpp
api/LogSessionData.cpp
api/Logger.cpp
api/LogManagerProvider.cpp
api/CorrelationVector.cpp
api/LogConfiguration.cpp
api/AuthTokensController.cpp
api/ILogConfiguration.cpp
api/LogManagerFactory.cpp
api/capi.cpp
api/DataViewerCollection.cpp
utils/FileUtils.cpp
utils/Utils.cpp
utils/StringUtils.cpp
utils/ZlibUtils.cpp
pal/InformationProviderImpl.cpp
http/HttpClient_CAPI.cpp
http/HttpClientManager.cpp
http/HttpRequestEncoder.cpp
http/HttpResponseDecoder.cpp
http/HttpClientFactory.cpp
stats/Statistics.cpp
stats/MetaStats.cpp
offline/StorageObserver.cpp
offline/OfflineStorageFactory.cpp
offline/MemoryStorage.cpp
offline/OfflineStorage_SQLite.cpp
offline/OfflineStorageHandler.cpp
offline/LogSessionDataProvider.cpp
backoff/IBackoff.cpp
pal/PAL.cpp
pal/TaskDispatcher_CAPI.cpp
pal/WorkerThread.cpp
)
# Support for Azure Monitor / Application Insights
if(BUILD_AZMON)
include(modules/azmon/CMakeLists.txt OPTIONAL)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/exp/)
list(APPEND SRCS
modules/exp/afd/afdclient/AFDClientUtils.cpp
modules/exp/afd/afdclient/AFDClient.cpp
modules/exp/afd/afdclient/AFDConfigCache.cpp
modules/exp/ecs/ecsclient/ECSClient.cpp
modules/exp/ecs/ecsclient/ECSClientUtils.cpp
modules/exp/ecs/ecsclient/ECSConfigCache.cpp
modules/exp/JsonHelper.cpp
modules/exp/EXPCommonClient.cpp
modules/exp/FifoFileStorage.cpp
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer/)
list(APPEND SRCS
modules/dataviewer/DefaultDataViewer.cpp
modules/dataviewer/OnDisableNotificationCollection.cpp
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUARD)
list(APPEND SRCS
modules/privacyguard/PrivacyGuard.cpp
modules/privacyguard/RegisteredFileTypes.cpp
modules/privacyguard/SummaryStatistics.cpp
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector/ AND BUILD_LIVEEVENTINSPECTOR)
list(APPEND SRCS
modules/liveeventinspector/LiveEventInspector.cpp
modules/liveeventinspector/LiveEventInspector.hpp
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/cds/ AND BUILD_CDS)
add_definitions(-DHAVE_MAT_CDS)
list(APPEND SRCS
modules/cds/CdsFactory.hpp
modules/cds/CdsFactory.cpp
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/signals/ AND BUILD_SIGNALS)
list(APPEND SRCS
modules/signals/Signals.cpp
modules/signals/SignalsEncoder.cpp
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/ AND BUILD_SANITIZER)
list(APPEND SRCS
modules/sanitizer/Sanitizer.cpp
modules/sanitizer/SanitizerProvider.cpp
modules/sanitizer/SanitizerStringUtils.cpp
modules/sanitizer/SanitizerTargets.cpp
modules/sanitizer/SanitizerTrie.cpp
modules/sanitizer/SanitizerTrieNode.cpp
)
endif()
if(PAL_IMPLEMENTATION STREQUAL "CPP11")
if(APPLE)
list(APPEND SRCS
pal/posix/sysinfo_utils_apple.cpp
)
if(BUILD_IOS)
list(APPEND SRCS
pal/posix/sysinfo_utils_ios.mm
)
else()
list(APPEND SRCS
pal/posix/sysinfo_utils_mac.mm
)
endif()
endif()
list(APPEND SRCS
pal/posix/DeviceInformationImpl.cpp
pal/posix/SystemInformationImpl.cpp
pal/posix/sysinfo_sources.cpp
)
if(APPLE)
if(BUILD_APPLE_HTTP OR BUILD_IOS)
list(APPEND SRCS
http/HttpClient_Apple.mm
)
else()
list(APPEND SRCS
http/HttpClient_Curl.cpp
http/HttpClient_Curl.hpp
)
endif()
list(APPEND SRCS
pal/posix/NetworkInformationImpl.mm
# TODO: this unit below needs to be deprecated and removed
../third_party/Reachability/ODWReachability.m
)
else()
list(APPEND SRCS
http/HttpClient_Curl.cpp
http/HttpClient_Curl.hpp
pal/posix/NetworkInformationImpl.cpp
)
endif()
if(APPLE AND BUILD_OBJC_WRAPPER)
message("Include ObjC Wrappers")
list(APPEND SRCS
../wrappers/obj-c/ODWLogger.mm
../wrappers/obj-c/ODWLogManager.mm
../wrappers/obj-c/ODWEventProperties.mm
../wrappers/obj-c/ODWLogConfiguration.mm
../wrappers/obj-c/ODWSemanticContext.mm
)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer/)
list(APPEND SRCS
../wrappers/obj-c/ODWDiagnosticDataViewer.mm
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUARD)
list(APPEND SRCS
../wrappers/obj-c/ODWCommonDataContext.mm
../wrappers/obj-c/ODWPrivacyGuard.mm
../wrappers/obj-c/ODWPrivacyGuardInitConfig.mm
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/ AND BUILD_SANITIZER)
list(APPEND SRCS
../wrappers/obj-c/ODWSanitizerInitConfig.mm
../wrappers/obj-c/ODWSanitizer.mm
)
endif()
endif()
if(APPLE AND BUILD_SWIFT_WRAPPER)
message("Building Swift Wrappers")
# Run swift build for the Swift Wrappers Package
string(TOLOWER ${CMAKE_BUILD_TYPE} LOWER_BUILD_TYPE)
execute_process(
COMMAND swift build
-c ${LOWER_BUILD_TYPE}
--scratch-path ${CMAKE_BINARY_DIR}/OneDSSwift
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../wrappers/swift
RESULT_VARIABLE SWIFT_BUILD_RESULT
)
if(SWIFT_BUILD_RESULT EQUAL 0)
message("Swift Wrappers build succeeded!")
else()
message(FATAL_ERROR, "Swift build failed with error code: ${SWIFT_BUILD_RESULT}")
endif()
endif()
elseif(PAL_IMPLEMENTATION STREQUAL "WIN32")
# Win32 Desktop for now.
# TODO: define a separate PAL for Win10 cmake build
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../zlib ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite)
add_definitions(-D_UNICODE -DUNICODE -DZLIB_WINAPI -DWIN32 -DMATSDK_PLATFORM_WINDOWS=1 -DMATSDK_SHARED_LIB=1 -D_UTC_SDK -DUSE_BOND -D_WINDOWS -D_USRDLL -DWINVER=_WIN32_WINNT_WIN7)
remove_definitions(-D_MBCS)
list(APPEND SRCS
http/HttpClient_WinInet.cpp
http/HttpClient_WinInet.hpp
pal/desktop/WindowsDesktopDeviceInformationImpl.cpp
pal/desktop/WindowsDesktopNetworkInformationImpl.cpp
pal/desktop/WindowsDesktopSystemInformationImpl.cpp
pal/desktop/WindowsEnvironmentInfo.hpp
pal/desktop/NetworkDetector.cpp
utils/StringConversion.cpp
)
# UTC module
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/utc)
list(APPEND SRCS
modules/utc/desktop/UtcHelpers.cpp
modules/utc/UtcTelemetrySystem.cpp
)
endif()
else()
message(FATAL_ERROR "No platform abstraction library configured. Set PAL_IMPLEMENTATION.")
endif()
# Filtering module
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/filter)
list(APPEND SRCS
modules/filter/CompliantByDefaultEventFilterModule.cpp
modules/filter/CompliantByDefaultFilterApi.cpp
modules/filter/LevelCheckingEventFilter.cpp
)
endif()
create_source_files_groups_per_folder(${SRCS})
# MinGW does not require pthread
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(Threads REQUIRED)
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(mat PUBLIC "-pthread")
endif()
endif()
if(BUILD_SHARED_LIBS STREQUAL "ON")
message("-- Building shared SDK library")
# include(FindCURL)
# find_package(CURL REQUIRED)
# set(CMAKE_REQUIRED_LIBRARIES "${CURL_LIBRARIES}")
# find_package(sqlite3 REQUIRED)
add_library(mat SHARED ${SRCS})
# Add flags for obtaining system UUID via IOKit
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_SHARED_LINKER_FLAGS
"-framework CoreFoundation -framework IOKit -framework Foundation"
)
endif()
#
# TODO: allow adding "${Tcmalloc_LIBRARIES}" to target_link_libraries for memory leak debugging
#
if (BUILD_STATIC_SQLITE STREQUAL "ON")
# Build dynamic library, but prefer statically linking sqlite3 and zlib
add_library(sqlite3 STATIC IMPORTED GLOBAL)
add_library(z STATIC IMPORTED GLOBAL)
target_link_libraries(mat PRIVATE sqlite3 PUBLIC z ${LIBS} "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" "${CMAKE_REQUIRED_LIBRARIES}")
else()
# Prefer shared libraries for sqlite3 and zlib
add_library(sqlite3 SHARED IMPORTED GLOBAL)
add_library(z SHARED IMPORTED GLOBAL)
target_link_libraries(mat PUBLIC sqlite3 PUBLIC z ${LIBS} "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" "${CMAKE_REQUIRED_LIBRARIES}")
endif()
# target_link_libraries(mat PUBLIC libsqlite3 libcurl.a libz.a libssl.a libcrypto.a "${SQLITE_LIBRARY}" "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" )
install(TARGETS mat EXPORT mat LIBRARY DESTINATION ${INSTALL_LIB_DIR})
else()
message("-- Building static SDK library")
add_library(mat STATIC ${SRCS})
if(LINK_STATIC_DEPENDS)
if(PAL_IMPLEMENTATION STREQUAL "WIN32")
target_link_libraries(mat ${LIBS} "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" )
else()
add_library(sqlite3 STATIC IMPORTED GLOBAL)
add_library(z STATIC IMPORTED GLOBAL)
#
# TODO: allow adding "${Tcmalloc_LIBRARIES}" to target_link_libraries for memory leak debugging
#
target_link_libraries(mat PRIVATE libsqlite3.a PUBLIC libz.a ${LIBS} "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" )
endif()
endif()
install(TARGETS mat EXPORT mat ARCHIVE DESTINATION ${INSTALL_LIB_DIR})
endif()
message("-- Library will be installed to ${INSTALL_LIB_DIR}")
#if(PAL_IMPLEMENTATION STREQUAL "CPP11")
# #target_link_libraries(mat PUBLIC libcurl.a libz.a libssl.a libcrypto.a "${SQLITE_LIBRARY}" "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" )
# #target_link_libraries(mat PUBLIC libsqlite3.a libz.a ${LIBS} "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" )
#endif()