forked from openthread/ot-nxp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
240 lines (210 loc) · 8.77 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
#
# Copyright (c) 2021, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
cmake_minimum_required(VERSION 3.10.2)
project(ot-nxp
VERSION 0.2.0
LANGUAGES C CXX ASM
)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
endif()
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/platform)
include(utils)
include(${OT_NXP_PLATFORM} OPTIONAL)
include(options)
otnxp_git_version(OT_PACKAGE_VERSION)
set(OT_PACKAGE_VERSION "${OT_PACKAGE_VERSION}" CACHE STRING "")
message(STATUS "Setting default package version: ${OT_PACKAGE_VERSION}")
message(STATUS "Package Version: ${OT_PACKAGE_VERSION}")
message(STATUS "NXP Platform: ${OT_NXP_PLATFORM}")
set(OT_PLATFORM_LIB openthread-${OT_NXP_PLATFORM})
set(NXP_DRIVER_LIB nxp-${OT_NXP_PLATFORM}-driver)
#Set default log level if not set
if (OT_STACK_ENABLE_LOG)
if (NOT OT_LOG_LEVEL)
set(OT_LOG_LEVEL INFO)
endif()
if (NOT OT_LOG_OUTPUT)
set(OT_LOG_OUTPUT APP)
endif()
else()
set(OT_LOG_LEVEL NONE)
set(OT_LOG_OUTPUT NONE)
endif()
if(OT_NCP_RTOS_HOST)
message(WARNING "select ot nxp ncp host, the openthread stack will be not compiled.")
add_library(ot-config INTERFACE)
add_library(openthread-cli-ftd INTERFACE)
add_library(openthread-ftd INTERFACE)
add_library(ot-cli-addons INTERFACE)
else()
add_subdirectory(openthread)
endif()
if(OT_APP_BR_FREERTOS)
if(NOT DEFINED OT_APP_CLI_FREERTOS_LWIP)
set(OT_APP_CLI_FREERTOS_LWIP ON CACHE BOOL "OT_APP_CLI_FREERTOS_LWIP")
endif()
if(NOT DEFINED OT_APP_CLI_FREERTOS_EPHEMERAL_KEY)
set(OT_APP_CLI_FREERTOS_EPHEMERAL_KEY ON CACHE BOOL "OT_APP_CLI_FREERTOS_EPHEMERAL_KEY")
endif()
if(OT_NXP_LWIP_WIFI)
if(NOT DEFINED OT_APP_CLI_FREERTOS_WIFI)
set(OT_APP_CLI_FREERTOS_WIFI ON CACHE BOOL "OT_APP_CLI_FREERTOS_WIFI")
endif()
endif()
if(NOT DEFINED OT_APP_THREAD_RATE_LIMIT)
# Limit of traffic sent to the Thread network in bits per second, "0" for no limit.
set(OT_APP_THREAD_RATE_LIMIT "0" CACHE STRING "OT_APP_THREAD_RATE_LIMIT")
endif()
string(TOUPPER ${OT_NXP_PLATFORM} OT_NXP_PLATFORM_UPPER)
target_compile_definitions(ot-config INTERFACE
-DOPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1
-DOPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE=1
-DOPENTHREAD_CONFIG_MULTICAST_DNS_PUBLIC_API_ENABLE=1
-DOPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1
-DOPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1
-DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=0
-DOPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS=3
-DOPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1
-DOPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE=1
-DOPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE=1
-DOPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE=0
-DOPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE=0
-DOT_APP_BR_LWIP_HOOKS_EN=1
-DOPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE=1
-DOPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE=1
-DOPENTHREAD_CONFIG_DNSSD_DISCOVERY_PROXY_ENABLE=1
OT_NXP_PLATFORM_${OT_NXP_PLATFORM_UPPER}
)
else()
if(NOT DEFINED OT_APP_THREAD_RATE_LIMIT)
# Limit of traffic sent to the Thread network in bits per second, "0" for no limit.
set(OT_APP_THREAD_RATE_LIMIT "0" CACHE STRING "OT_APP_THREAD_RATE_LIMIT")
endif()
endif()
if(OT_NXP_LWIP)
# Workaround to avoid API conflict between LWIP and OT's TCPLP libs
# They have some API's with the same name but different implementation, so no compatible
# In case OT_NXP_LWIP is enabled, we have to exclude TCPLP from the build
set(OT_EXCLUDE_TCPLP_LIB ON)
# As TCPLP lib is excluded from the build, we have to disable OT TCP feature
target_compile_definitions(ot-config INTERFACE
-DOPENTHREAD_CONFIG_TCP_ENABLE=0
)
endif()
# If OT logging is enabled add a dependency to SDK log components
if (OT_STACK_ENABLE_LOG)
target_link_libraries(ot-config
INTERFACE
${NXP_DRIVER_LIB})
target_compile_definitions(ot-config
INTERFACE
-DOT_STACK_ENABLE_LOG)
endif ()
set(CONFIG_FILE "\"openthread-core-${OT_NXP_PLATFORM}-config.h\"")
set(CORE_CONFIG_FILE ${CONFIG_FILE})
set(CORE_CONFIG_CHECK "\"openthread-core-${OT_NXP_PLATFORM}-config-check.h\"")
target_compile_definitions(ot-config INTERFACE
OPENTHREAD_CONFIG_FILE=${CONFIG_FILE}
OPENTHREAD_PROJECT_CORE_CONFIG_FILE=${CORE_CONFIG_FILE}
OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=${CORE_CONFIG_CHECK}
)
if(OT_NXP_PLATFORM_FAMILY)
target_include_directories(ot-config INTERFACE
${PROJECT_SOURCE_DIR}/src/${OT_NXP_PLATFORM_FAMILY}/${OT_NXP_PLATFORM}
)
else()
target_include_directories(ot-config INTERFACE
${PROJECT_SOURCE_DIR}/src/${OT_NXP_PLATFORM}
)
endif()
if(NOT FREERTOS_CONFIG_FILE_DIRECTORY)
set(FREERTOS_CONFIG_FILE_DIRECTORY ${PROJECT_SOURCE_DIR}/boards/${OT_NXP_BOARD}/freertos CACHE STRING "")
endif()
# Give the possibility to the user to define his own path to board files
if(OT_NXP_BOARD_PATH)
message(STATUS "Using user defined board folder:\n"
"${OT_NXP_BOARD_PATH}"
)
if(NOT NXP_BOARD_LIB)
message(WARNING "The name of the board lib is not specified. It may not be linked properly by ot-nxp targets\n"
"You can add the link dependency in your projet:\n"
"target_link_libraries(<ot-nxp-target> <your board target>)\n"
"Or you can define the name of your board library:\n"
"-DNXP_BOARD_LIB=<name of the board lib>\n"
"or set it in your project before including ot-nxp:\n"
"set(NXP_BOARD_LIB <name of the board lib>)"
)
endif()
add_subdirectory(${OT_NXP_BOARD_PATH} ${PROJECT_BINARY_DIR}/board)
elseif(OT_NXP_BOARD) # TODO: move to "else" when all boards are supported
set(NXP_BOARD_LIB nxp-${OT_NXP_BOARD}-board)
add_subdirectory(boards)
else()
# TODO: enable following message when all boards are supported
# if(NOT OT_NXP_BOARD)
# message(FATAL_ERROR "Board is not defined. Please specify to board to build:\n"
# "-DOT_NXP_BOARD=<board name>"
# )
# endif()
endif()
if(NOT NXP_SDK_ROOT)
# Provide a default path to MCUXpresso SDK as if ot-nxp is located in <path to sdk>/middleware/wireless/
set(NXP_SDK_ROOT ${PROJECT_SOURCE_DIR}/../../../)
endif()
# Determine whether the SDK used is the github repo, a package or the internal repo
if(EXISTS ${NXP_SDK_ROOT}/core/.github)
set(SDK_TYPE "GITHUB")
elseif(EXISTS ${NXP_SDK_ROOT}/SW-Content-Register.txt)
set(SDK_TYPE "PACKAGE")
else()
set(SDK_TYPE "INTERNAL")
endif()
message(STATUS "SDK_TYPE: ${SDK_TYPE}")
add_subdirectory(third_party)
add_subdirectory(src)
add_subdirectory(examples)
if(OT_NXP_POST_BUILD_COMMAND)
run_post_build_command()
endif()
if(OT_NXP_EXPORT_TO_BIN)
export_all_targets_to_bin()
endif()
if(OT_NXP_EXPORT_TO_SREC)
export_all_targets_to_srec()
endif()