-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
268 lines (217 loc) · 5.7 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
# Copyright 2019-2021, 2024 NXP
#
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.5)
PROJECT(nxp_iot_agent LANGUAGES C)
IF(NOT COMMAND CREATE_BINARY)
MACRO(CREATE_BINARY PROJECT_NAME)
ENDMACRO()
ENDIF()
IF(NXP_IOT_AGENT_HAVE_PSA_IMPL_SMW)
add_definitions(-DNXP_IOT_AGENT_HAVE_PSA_IMPL_SMW)
ENDIF()
FILE(
GLOB
NXP_IOT_AGENT_FILES
inc/*.h
inc/*.h.in
src/*.c
src/protobuf/*.h
src/protobuf/*.c
)
IF(SSS_HAVE_APPLET_A71CH)
MESSAGE(FATAL_ERROR "A71CH is not supported anymore for nxp_iot_agent!!!")
ENDIF()
IF(SSS_HAVE_HOST_PCWINDOWS)
FILE(
GLOB
NXP_IOT_AGENT_WINDOWS_FILES
platform/windows/*.h
platform/windows/*.h.in
platform/windows/*.c
)
set(NXP_IOT_AGENT_FILES ${NXP_IOT_AGENT_FILES} ${NXP_IOT_AGENT_WINDOWS_FILES})
ENDIF()
IF(SSS_HAVE_HOSTCRYPTO_OPENSSL)
FILE(
GLOB
NXP_IOT_AGENT_OPENSSL_FILES
platform/openssl/*.h
platform/openssl/*.h.in
platform/openssl/*.c
)
set(NXP_IOT_AGENT_FILES ${NXP_IOT_AGENT_FILES} ${NXP_IOT_AGENT_OPENSSL_FILES})
ENDIF()
IF(SSS_HAVE_HOSTCRYPTO_MBEDTLS)
FILE(
GLOB
NXP_IOT_AGENT_MBEDTLS_FILES
platform/mbedtls/network_mbedtls.h
platform/mbedtls/network_mbedtls.c
)
set(NXP_IOT_AGENT_FILES ${NXP_IOT_AGENT_FILES} ${NXP_IOT_AGENT_MBEDTLS_FILES})
ENDIF()
IF(SSS_HAVE_HOST_FRDMK64F OR SSS_HAVE_HOST_EVKMIMXRT1060 OR SSS_HAVE_HOST_EVKMIMXRT1170)
FILE(
GLOB
NXP_IOT_AGENT_PORT_FILES
platform/mbedtls/net_lwip.c
)
SET(NXP_IOT_AGENT_FILES ${NXP_IOT_AGENT_FILES} ${NXP_IOT_AGENT_PORT_FILES})
ENDIF()
IF(SSS_HAVE_HOST_LPCXPRESSO55S)
FILE(
GLOB
NXP_IOT_AGENT_PORT_FILES
platform/mbedtls/net_lpc_mwm.c
)
SET(NXP_IOT_AGENT_FILES ${NXP_IOT_AGENT_FILES} ${NXP_IOT_AGENT_PORT_FILES})
ENDIF()
IF(SSS_HAVE_MBEDTLS_ALT_PSA AND NOT NXP_IOT_AGENT_HAVE_PSA_IMPL_SMW)
# TODO: remove this once the unwrapping is part of mbedtls.
set(NXP_IOT_AGENT_FILES ${NXP_IOT_AGENT_FILES} ex/src/utils/mbedtls_psa/psa_crypto_wrapper.c)
ENDIF()
IF(NXP_IOT_AGENT_HAVE_PSA_IMPL_SMW)
set(NXP_IOT_AGENT_FILES ${NXP_IOT_AGENT_FILES} platform/smw/device_mgr.c)
ENDIF()
ADD_LIBRARY(nxp_iot_agent ${NXP_IOT_AGENT_FILES})
IF(SSS_HAVE_MBEDTLS_ALT_PSA AND NOT NXP_IOT_AGENT_HAVE_PSA_IMPL_SMW)
# TODO: remove this once the unwrapping is part of mbedtls.
TARGET_INCLUDE_DIRECTORIES(nxp_iot_agent PUBLIC ex/inc/mbedtls_psa)
ENDIF()
IF(
CMAKE_CXX_COMPILER
MATCHES
".*clang"
OR CMAKE_CXX_COMPILER_ID
STREQUAL
"AppleClang"
)
TARGET_COMPILE_OPTIONS(
${PROJECT_NAME}
PUBLIC -Wno-format
PUBLIC -Wno-error=format)
ENDIF()
TARGET_INCLUDE_DIRECTORIES(
nxp_iot_agent
PUBLIC inc
PUBLIC platform
PUBLIC src/protobuf
)
IF(SSS_HAVE_KSDK)
TARGET_INCLUDE_DIRECTORIES(
nxp_iot_agent
PUBLIC port/ksdk
)
ELSE()
TARGET_INCLUDE_DIRECTORIES(
nxp_iot_agent
PUBLIC port/default
)
ENDIF()
IF(SSS_HAVE_HOSTCRYPTO_MBEDTLS AND NOT NXP_IOT_AGENT_HAVE_PSA_IMPL_SMW)
IF (SSS_HAVE_MBEDTLS_ALT_PSA)
TARGET_LINK_LIBRARIES(
nxp_iot_agent
mbedtls_psa
)
ELSE()
TARGET_LINK_LIBRARIES(
nxp_iot_agent
mbedtls
)
ENDIF()
ENDIF()
IF(NXP_IOT_AGENT_HAVE_PSA_IMPL_SMW)
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
PUBLIC platform/smw
)
FIND_PACKAGE(NXP_SMW CONFIG REQUIRED)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} NXP_SMW::smw)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} pthread)
FIND_PACKAGE(MbedTLS CONFIG REQUIRED)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} MbedTLS::mbedtls)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} MbedTLS::mbedx509)
ADD_SUBDIRECTORY(src/common)
ENDIF()
IF(SSS_HAVE_HOST_PCWINDOWS OR SSS_HAVE_HOST_WIN10IOT)
TARGET_INCLUDE_DIRECTORIES(
nxp_iot_agent
PUBLIC platform/windows
)
ENDIF()
IF(SSS_HAVE_HOSTCRYPTO_OPENSSL)
TARGET_LINK_LIBRARIES(
nxp_iot_agent
${OPENSSL_LIBRARIES}
)
IF(SSS_HAVE_HOST_PCWINDOWS)
TARGET_LINK_LIBRARIES(
nxp_iot_agent
crypt32
)
ENDIF()
TARGET_INCLUDE_DIRECTORIES(
nxp_iot_agent
PUBLIC platform/openssl
)
TARGET_COMPILE_DEFINITIONS(nxp_iot_agent PRIVATE OPENSSL_LOAD_CONF)
ENDIF()
IF(SSS_HAVE_HOSTCRYPTO_MBEDTLS)
TARGET_LINK_LIBRARIES(
nxp_iot_agent
)
TARGET_INCLUDE_DIRECTORIES(
nxp_iot_agent
PUBLIC platform/mbedtls
)
ENDIF()
IF(SSS_HAVE_APPLET_SE05X_IOT)
TARGET_LINK_LIBRARIES(
nxp_iot_agent
smCom
ex_common
SSS_APIs
se05x
)
ENDIF()
TARGET_COMPILE_DEFINITIONS(nxp_iot_agent PRIVATE PB_FIELD_32BIT)
IF (WIN32)
SET(LIBS_SYSTEM ws2_32)
ENDIF()
TARGET_LINK_LIBRARIES(
nxp_iot_agent
nxp_iot_agent_common
${LIBS_SYSTEM}
)
ADD_SUBDIRECTORY(ex)
IF(SSS_HAVE_RTOS_DEFAULT AND NXPInternal)
ADD_SUBDIRECTORY(tst)
ENDIF()
IF(SSS_HAVE_HOST_PCLINUX OR SSS_HAVE_HOST_IMXLINUX)
INSTALL(TARGETS nxp_iot_agent DESTINATION lib)
ENDIF()
IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
TARGET_COMPILE_OPTIONS(
${PROJECT_NAME}
PUBLIC
/wd4267 # '=': conversion from 'size_t' to 'int', possible loss of data
PUBLIC
/wd4477 # 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'size_t'
PUBLIC
/wd4127 # conditional expression is constant
)
ENDIF()
# TODO: Get rid of -Wno-format -Wno-format-security
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
TARGET_COMPILE_OPTIONS(
${PROJECT_NAME}
PRIVATE -Wno-error=format
PRIVATE -Wno-format
PRIVATE -Wno-error=format-security
PRIVATE -Wno-format-security
PRIVATE -Wno-address-of-packed-member
PRIVATE -Wno-incompatible-pointer-types
)
ENDIF()