forked from Azure/iot-hub-device-update
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
376 lines (305 loc) · 9.63 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
cmake_minimum_required (VERSION 3.5)
project (azure_device_update_client)
# Print out CMake build variables.
message (STATUS)
message (STATUS CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
message (STATUS CMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION})
message (STATUS CMAKE_HOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME})
message (STATUS CMAKE_GENERATOR=${CMAKE_GENERATOR})
message (STATUS CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
message (STATUS CMAKE_C_COMPILER=${CMAKE_C_COMPILER})
message (STATUS CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
message (STATUS CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR})
message (STATUS CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR})
message (STATUS CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
message (STATUS CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
message (STATUS)
# Tell CMake where to find our custom CMake module files.
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# GNUInstallDirs defines the standard GNU install directories
# so that we can reference them in our install commands.
# e.g. CMAKE_INSTALL_BINDIR
include (GNUInstallDirs)
include (aduc_helpers)
#
# Version information
#
# ADU Agent follows Semantic Versioning 2.0.0
# https://semver.org/spec/v2.0.0.html
set_cache_with_env_or_default (
ADUC_VERSION_MAJOR
"0"
STRING
"The major part of the semantic version")
set_cache_with_env_or_default (
ADUC_VERSION_MINOR
"8"
STRING
"The minor part of the semantic version")
set_cache_with_env_or_default (
ADUC_VERSION_PATCH
"2"
STRING
"The patch part of the semantic version")
set_cache_with_env_or_default (
ADUC_VERSION_PRERELEASE
"public-preview"
STRING
"The pre-release part of the semantic version")
set_cache_with_env_or_default (
ADUC_VERSION_BUILD
""
STRING
"The build ID part of the semantic version")
set_cache_with_env_or_default (
ENABLE_ADU_TELEMETRY_REPORTING
ON
BOOL
"The flag to turn on/off reporting versions to telemetry")
set_cache_with_env_or_default (
ADUC_BUILDER_IDENTIFIER
"DU"
STRING
"The ADUC builder name: ADUC-sourced builder will be called DU")
set (ADUC_VERSION "${ADUC_VERSION_MAJOR}.${ADUC_VERSION_MINOR}.${ADUC_VERSION_PATCH}")
if (ADUC_VERSION_PRERELEASE)
string (APPEND ADUC_VERSION "-${ADUC_VERSION_PRERELEASE}")
endif ()
if (ADUC_VERSION_BUILD)
string (APPEND ADUC_VERSION "+${ADUC_VERSION_BUILD}")
endif ()
#
# Custom CMake Options
#
set (
ADUC_CONF_FOLDER
"/etc/adu"
CACHE STRING "Path to the configuration folder for the ADU Agent.")
set (
ADUC_CONF_FILE
"du-config.json"
CACHE STRING "Name of the ADU Agent configuration file.")
set (
ADUC_DATA_FOLDER
"/var/lib/adu"
CACHE
STRING
"Path to the folder containing data file(s) for the ADU Agent. e.g. installedcriteria file."
)
set (
ADUC_TEST_DATA_PATH_SEGMENT
"testdata"
CACHE STRING
"The path segment in source tree where testdata for various test folders will be found.")
set (
ADUC_TEST_DATA_FOLDER
"/tmp/adu/${ADUC_TEST_DATA_PATH_SEGMENT}"
CACHE
STRING
"Path to the folder containing test data file(s) copied from tests/testdata/<testname> folders in the source tree."
)
set (
ADUC_EXTENSIONS_FOLDER
"${ADUC_DATA_FOLDER}/extensions"
CACHE STRING "Path to the folder containing file(s) related to DU Agent extension(s).")
set (
ADUC_EXTENSIONS_INSTALL_FOLDER
"${ADUC_EXTENSIONS_FOLDER}/sources"
CACHE STRING "Path to the folder containing extensions .so file(s).")
set (
ADUC_UPDATE_CONTENT_HANDLER_REG_FILENAME
"content_handler.json"
CACHE STRING "Content handler registration file name.")
set (
ADUC_EXTENSION_REG_FILENAME
"extension.json"
CACHE STRING "Extension registration file name.")
set (
ADUC_EXTENSIONS_SUBDIR_COMPONENT_ENUMERATOR
"component_enumerator"
CACHE STRING "Sub folder for component enumerator extension.")
set (
ADUC_EXTENSIONS_SUBDIR_CONTENT_DOWNLOADER
"content_downloader"
CACHE STRING "Sub folder for content downloader extension.")
set (
ADUC_EXTENSIONS_SUBDIR_UPDATE_CONTENT_HANDLERS
"update_content_handlers"
CACHE STRING "Sub folder for update content handler extensions.")
set (
ADUC_COMPONENT_ENUMERATOR_EXTENSION_DIR
"${ADUC_EXTENSIONS_FOLDER}/${ADUC_EXTENSIONS_SUBDIR_COMPONENT_ENUMERATOR}"
CACHE STRING "Path for component enumerator extension.")
set (
ADUC_CONTENT_DOWNLOADER_EXTENSION_DIR
"${ADUC_EXTENSIONS_FOLDER}/${ADUC_EXTENSIONS_SUBDIR_CONTENT_DOWNLOADER}"
CACHE STRING "Path for content downloader extension.")
set (
ADUC_UPDATE_CONTENT_HANDLER_EXTENSION_DIR
"${ADUC_EXTENSIONS_FOLDER}/${ADUC_EXTENSIONS_SUBDIR_UPDATE_CONTENT_HANDLERS}"
CACHE STRING "Sub folder for update content handler extensions.")
set (
ADUC_DOWNLOADS_FOLDER
"${ADUC_DATA_FOLDER}/downloads"
CACHE STRING "Path to the folder containing downloaded update artifacts.")
set (
ADUC_CONTENT_HANDLERS
"microsoft/swupdate"
CACHE STRING "The list of content handlers.")
#
# DeviceInfo configuration
# These values must be modified to describe your device.
#
set (
ADUC_DEVICEINFO_MANUFACTURER
"Contoso"
CACHE STRING "Manufacturer of the device.")
set (
ADUC_DEVICEINFO_MODEL
"Virtual Machine"
CACHE STRING "Name of the device.")
#
# AzureDeviceUpdateInterface DeviceProperties configuration
#
set (
ADUC_DEVICEPROPERTIES_MANUFACTURER
"Contoso"
CACHE STRING "Manufacturer of the device")
set (
ADUC_DEVICEPROPERTIES_MODEL
"Video"
CACHE STRING "Model of the device")
set (
ADUC_PLATFORM_LAYER
"linux"
CACHE STRING "The platform layer to use. Options: simulator linux")
# By default ADU Agent daemon runs as root.
# root user home directory should be /root.
set (
ADUC_HOME_FOLDER
"/root"
CACHE STRING "Path to the ADU Agent home folder.")
set (
ADUC_INSTALLEDCRITERIA_FILE
"installedcriteria"
CACHE STRING "Name of the data file containing InstalledCriteria records.")
set (
ADUC_LOGGING_LIBRARY
"zlog"
CACHE STRING "The logging library to use. Options: xlog zlog")
set (
ADUC_LOG_FOLDER
"/var/log/adu"
CACHE STRING "Location where ADU Agent will write logs.")
set (
ADUC_VERSION_FILE
"/etc/adu-version"
CACHE STRING "Path to the file that contains version info for the image or device.")
set (
ADUC_AGENT_FOLDER
"/usr/bin"
CACHE STRING "Location where ADU Agent binary is located.")
set (
ADUC_AGENT_FILENAME
"AducIotAgent"
CACHE STRING "The filename of the ADU Agent binary.")
get_filename_component (
ADUC_AGENT_FILEPATH
"${ADUC_AGENT_FOLDER}/${ADUC_AGENT_FILENAME}"
ABSOLUTE
"/")
set (
DIAGNOSTICS_CONFIG_FILE
"du-diagnostics-config.json"
CACHE STRING
"Path to the file that contains the configuration information for the diagnostics system")
set (
DIAGNOSTICS_COMPLETED_OPERATION_FILE
"diagnosticsoperationids"
CACHE STRING "File that contains the last completed diagnostic operation's id")
set (
DIAGNOSTICS_COMPLETED_OPERATION_FILE_PATH
"${ADUC_DATA_FOLDER}/${DIAGNOSTICS_COMPLETED_OPERATION_FILE}"
CACHE STRING "Path to the file that contains the completed diagnostic operation ids")
set (
ADUSHELL_FOLDER
"/usr/lib/adu"
CACHE STRING "The directory of the adu-shell binary.")
set (
ADUSHELL_FILENAME
"adu-shell"
CACHE STRING "Filename of adu-shell.")
get_filename_component (
ADUSHELL_FILE_PATH
"${ADUSHELL_FOLDER}/${ADUSHELL_FILENAME}"
ABSOLUTE
"/")
set (
ADUSHELL_FILE_PATH
${ADUSHELL_FILE_PATH}
CACHE STRING "The absolute path to the adu-shell file path.")
set (
ADUSHELL_EFFECTIVE_GROUP_NAME
"adu"
CACHE STRING "The effective group name for adu-shell process.")
set (
ADUC_FILE_USER
"adu"
CACHE STRING "The user for adu file ownership.")
set (
ADUC_FILE_GROUP
"adu"
CACHE STRING "The group for adu file ownership.")
set (
DO_FILE_USER
"do"
CACHE STRING "The user for do file ownership.")
set (
DO_FILE_GROUP
"do"
CACHE STRING "The group for do file ownership.")
set (
SYSLOG_FILE_GROUP
"syslog"
CACHE STRING "The syslog group.")
option (ADUC_WARNINGS_AS_ERRORS "Treat warnings as errors (-Werror)" ON)
option (ADUC_BUILD_UNIT_TESTS "Build unit tests and mock some functionality" OFF)
option (ADUC_BUILD_DOCUMENTATION "Build documentation files" OFF)
option (ADUC_BUILD_PACKAGES "Build the ADU Agent packages" OFF)
option (ADUC_INSTALL_DAEMON "Install the ADU Agent as a daemon" ON)
option (ADUC_REGISTER_DAEMON "Register the ADU Agent daemon with the system" ON)
### End CMake Options
# Construct the absolute path to the adu configuration file.
get_filename_component (
ADUC_CONF_FILE_PATH
"${ADUC_CONF_FOLDER}/${ADUC_CONF_FILE}"
ABSOLUTE
"/")
set (
ADUC_CONF_FILE_PATH
"${ADUC_CONF_FILE_PATH}"
CACHE STRING "Path to the ADU configuration file.")
# Construct the absolute path to the adu diagnostics configuration file
get_filename_component (
DIAGNOSTICS_CONFIG_FILE_PATH
"${ADUC_CONF_FOLDER}/${DIAGNOSTICS_CONFIG_FILE}"
ABSOLUTE
"/")
set (
DIAGNOSTICS_CONFIG_FILE_PATH
"${DIAGNOSTICS_CONFIG_FILE_PATH}"
CACHE STRING "Path to the diagnostics configuration file.")
if (ADUC_BUILD_UNIT_TESTS)
# Need to be in the root directory to place CTestTestfile.cmake in root
# of output folder.
enable_testing ()
copy_test_data ("${CMAKE_SOURCE_DIR}" "${ADUC_TEST_DATA_PATH_SEGMENT}"
"${ADUC_TEST_DATA_FOLDER}")
endif ()
if (ADUC_INSTALL_DAEMON)
add_subdirectory (daemon)
endif ()
add_subdirectory (src)
if (ADUC_BUILD_PACKAGES)
add_subdirectory (packages)
endif ()