1# 2# Copyright (c) 2019, The OpenThread Authors. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# 2. Redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution. 12# 3. Neither the name of the copyright holder nor the 13# names of its contributors may be used to endorse or promote products 14# derived from this software without specific prior written permission. 15# 16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26# POSSIBILITY OF SUCH DAMAGE. 27# 28 29option(OT_APP_CLI "enable CLI app" ON) 30option(OT_APP_NCP "enable NCP app" ON) 31option(OT_APP_RCP "enable RCP app" ON) 32 33option(OT_FTD "enable FTD" ON) 34option(OT_MTD "enable MTD" ON) 35option(OT_RCP "enable RCP" ON) 36 37option(OT_ANYCAST_LOCATOR "enable anycast locator support") 38if(OT_ANYCAST_LOCATOR) 39 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE=1") 40endif() 41 42option(OT_ASSERT "enable assert function OT_ASSERT()" ON) 43if(OT_ASSERT) 44 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=1") 45else() 46 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=0") 47endif() 48 49option(OT_BACKBONE_ROUTER "enable backbone router functionality") 50if(OT_BACKBONE_ROUTER) 51 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1") 52 set(OT_BACKBONE_ROUTER_DUA_NDPROXYING ON CACHE BOOL "Enable DUA NDProxying by default") 53 set(OT_BACKBONE_ROUTER_MULTICAST_ROUTING ON CACHE BOOL "Enable Multicast Routing by default") 54endif() 55 56option(OT_BACKBONE_ROUTER_DUA_NDPROXYING "enable Backbone Router DUA ND Proxying functionality" OFF) 57if(OT_BACKBONE_ROUTER_DUA_NDPROXYING) 58 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=1") 59else() 60 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=0") 61endif() 62 63option(OT_BACKBONE_ROUTER_MULTICAST_ROUTING "enable Backbone Router Multicast Routing functionality" OFF) 64if(OT_BACKBONE_ROUTER_MULTICAST_ROUTING) 65 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=1") 66else() 67 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=0") 68endif() 69 70option(OT_BORDER_AGENT "enable border agent support") 71if(OT_BORDER_AGENT) 72 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1") 73endif() 74 75option(OT_BORDER_ROUTER "enable border router support") 76if(OT_BORDER_ROUTER) 77 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1") 78endif() 79 80option(OT_BORDER_ROUTING "enable border routing support") 81if(OT_BORDER_ROUTING) 82 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1") 83endif() 84 85option(OT_BORDER_ROUTING_NAT64 "enable border routing NAT64 support") 86if(OT_BORDER_ROUTING_NAT64) 87 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE=1") 88endif() 89 90if(NOT OT_EXTERNAL_MBEDTLS) 91 set(OT_MBEDTLS mbedtls) 92 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=1") 93else() 94 set(OT_MBEDTLS ${OT_EXTERNAL_MBEDTLS}) 95 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=0") 96endif() 97 98option(OT_BUILTIN_MBEDTLS_MANAGEMENT "enable builtin mbedtls management" ON) 99if(OT_BUILTIN_MBEDTLS_MANAGEMENT) 100 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=1") 101else() 102 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=0") 103endif() 104 105option(OT_CHANNEL_MANAGER "enable channel manager support") 106if(OT_CHANNEL_MANAGER) 107 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1") 108endif() 109 110option(OT_CHANNEL_MONITOR "enable channel monitor support") 111if(OT_CHANNEL_MONITOR) 112 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1") 113endif() 114 115option(OT_CHILD_SUPERVISION "enable child supervision support") 116if(OT_CHILD_SUPERVISION) 117 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1") 118endif() 119 120option(OT_COAP "enable coap api support") 121if(OT_COAP) 122 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_API_ENABLE=1") 123endif() 124 125option(OT_COAPS "enable secure coap api support") 126if(OT_COAPS) 127 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1") 128endif() 129 130option(OT_COAP_BLOCK "enable coap block-wise transfer (RFC7959) api support") 131if(OT_COAP_BLOCK) 132 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE=1") 133endif() 134 135option(OT_COAP_OBSERVE "enable coap observe (RFC7641) api support") 136if(OT_COAP_OBSERVE) 137 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE=1") 138endif() 139 140option(OT_COMMISSIONER "enable commissioner support") 141if(OT_COMMISSIONER) 142 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1") 143endif() 144 145option(OT_CSL_RECEIVER "enable csl receiver") 146if(OT_CSL_RECEIVER) 147 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1") 148endif() 149 150option(OT_CSL_AUTO_SYNC "enable data polling based on csl config" ${OT_CSL_RECEIVER}) 151if(OT_CSL_AUTO_SYNC) 152 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=1") 153else() 154 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=0") 155endif() 156 157option(OT_CSL_DEBUG "enable csl debug") 158if(OT_CSL_DEBUG) 159 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE=1") 160endif() 161 162option(OT_DATASET_UPDATER "enable dataset updater support") 163if(OT_DATASET_UPDATER) 164 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1") 165endif() 166 167option(OT_DHCP6_CLIENT "enable DHCP6 client support") 168if(OT_DHCP6_CLIENT) 169 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1") 170endif() 171 172option(OT_DHCP6_SERVER "enable DHCP6 server support") 173if(OT_DHCP6_SERVER) 174 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1") 175endif() 176 177option(OT_DIAGNOSTIC "enable diagnostic support") 178if(OT_DIAGNOSTIC) 179 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DIAG_ENABLE=1") 180endif() 181 182option(OT_DNS_CLIENT "enable DNS client support") 183if(OT_DNS_CLIENT) 184 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1") 185endif() 186 187option(OT_DNS_DSO "enable DNS Stateful Operations (DSO) support") 188if(OT_DNS_DSO) 189 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNS_DSO_ENABLE=1") 190endif() 191 192option(OT_DNSSD_SERVER "enable DNS-SD server support") 193if(OT_DNSSD_SERVER) 194 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE=1") 195endif() 196 197option(OT_DOC "Build OpenThread documentation") 198 199option(OT_ECDSA "enable ECDSA support") 200if(OT_ECDSA) 201 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ECDSA_ENABLE=1") 202endif() 203 204option(OT_SRP_CLIENT "enable SRP client support") 205if (OT_SRP_CLIENT) 206 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1") 207endif() 208 209option(OT_DUA "enable Domain Unicast Address feature for Thread 1.2") 210if(OT_DUA) 211 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DUA_ENABLE=1") 212endif() 213 214option(OT_MESSAGE_USE_HEAP "enable heap allocator for message buffers") 215if(OT_MESSAGE_USE_HEAP) 216 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1") 217endif() 218 219option(OT_MLR "enable Multicast Listener Registration feature for Thread 1.2") 220if(OT_MLR) 221 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLR_ENABLE=1") 222endif() 223 224option(OT_EXTERNAL_HEAP "enable external heap support") 225if(OT_EXTERNAL_HEAP) 226 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1") 227endif() 228 229option(OT_HISTORY_TRACKER "enable history tracker support") 230if(OT_HISTORY_TRACKER) 231 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE=1") 232endif() 233 234option(OT_IP6_FRAGM "enable ipv6 fragmentation support") 235if(OT_IP6_FRAGM) 236 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1") 237endif() 238 239option(OT_JAM_DETECTION "enable jam detection support") 240if(OT_JAM_DETECTION) 241 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1") 242endif() 243 244option(OT_JOINER "enable joiner support") 245if(OT_JOINER) 246 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JOINER_ENABLE=1") 247endif() 248 249option(OT_LEGACY "enable legacy network support") 250if(OT_LEGACY) 251 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LEGACY_ENABLE=1") 252endif() 253 254option(OT_LINK_RAW "enable link raw service") 255if(OT_LINK_RAW) 256 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LINK_RAW_ENABLE=1") 257endif() 258 259option(OT_LINK_METRICS_INITIATOR "enable link metrics initiator") 260if (OT_LINK_METRICS_INITIATOR) 261 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE=1") 262endif() 263 264option(OT_LINK_METRICS_SUBJECT "enable link metrics subject") 265if (OT_LINK_METRICS_SUBJECT) 266 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE=1") 267endif() 268 269option(OT_LOG_LEVEL_DYNAMIC "enable dynamic log level control") 270if(OT_LOG_LEVEL_DYNAMIC) 271 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1") 272endif() 273 274option(OT_MAC_FILTER "enable mac filter support") 275if(OT_MAC_FILTER) 276 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1") 277endif() 278 279option(OT_MLE_LONG_ROUTES "enable MLE long routes extension (experimental, breaks Thread conformance)") 280if(OT_MLE_LONG_ROUTES) 281 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE=1") 282endif() 283 284option(OT_MTD_NETDIAG "enable TMF network diagnostics on MTDs") 285if(OT_MTD_NETDIAG) 286 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1") 287endif() 288 289option(OT_MULTIPLE_INSTANCE "enable multiple instances") 290if(OT_MULTIPLE_INSTANCE) 291 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE=1") 292endif() 293 294option(OT_NEIGHBOR_DISCOVERY_AGENT "enable neighbor discovery agent support") 295if(OT_NEIGHBOR_DISCOVERY_AGENT) 296 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE=1") 297endif() 298 299option(OT_NETDATA_PUBLISHER "enable Thread Network Data publisher") 300if(OT_NETDATA_PUBLISHER) 301 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE=1") 302endif() 303 304option(OT_PING_SENDER "enable ping sender support" ${OT_APP_CLI}) 305if(OT_PING_SENDER) 306 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PING_SENDER_ENABLE=1") 307endif() 308 309option(OT_PLATFORM_NETIF "enable platform netif support") 310if(OT_PLATFORM_NETIF) 311 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1") 312endif() 313 314option(OT_PLATFORM_UDP "enable platform UDP support") 315if(OT_PLATFORM_UDP) 316 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1") 317endif() 318 319if(OT_POSIX_SETTINGS_PATH) 320 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH=${OT_POSIX_SETTINGS_PATH}") 321endif() 322 323option(OT_REFERENCE_DEVICE "enable Thread Test Harness reference device support") 324if(OT_REFERENCE_DEVICE) 325 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1") 326endif() 327 328option(OT_SERVICE "enable support for injecting Service entries into the Thread Network Data") 329if(OT_SERVICE) 330 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1") 331endif() 332 333option(OT_SETTINGS_RAM "enable volatile-only storage of settings") 334if(OT_SETTINGS_RAM) 335 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SETTINGS_RAM=1") 336endif() 337 338option(OT_SLAAC "enable support for adding of auto-configured SLAAC addresses by OpenThread") 339if(OT_SLAAC) 340 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1") 341endif() 342 343option(OT_SNTP_CLIENT "enable SNTP Client support") 344if(OT_SNTP_CLIENT) 345 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1") 346endif() 347 348option(OT_SRP_SERVER "enable SRP server") 349if (OT_SRP_SERVER) 350 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SRP_SERVER_ENABLE=1") 351endif() 352 353option(OT_TIME_SYNC "enable the time synchronization service feature") 354if(OT_TIME_SYNC) 355 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1") 356endif() 357 358option(OT_TREL "enable TREL radio link for Thread over Infrastructure feature") 359if (OT_TREL) 360 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1") 361endif() 362 363option(OT_TX_BEACON_PAYLOAD "enable Thread beacon payload in outgoing beacons") 364if (OT_TX_BEACON_PAYLOAD) 365 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_OUTGOING_BEACON_PAYLOAD_ENABLE=1") 366endif() 367 368option(OT_UDP_FORWARD "enable UDP forward support") 369if(OT_UDP_FORWARD) 370 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1") 371endif() 372 373option(OT_UPTIME "enable support for tracking OpenThread instance's uptime") 374if(OT_UPTIME) 375 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_UPTIME_ENABLE=1") 376endif() 377 378option(OT_FIREWALL "enable firewall") 379if (OT_FIREWALL) 380 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_POSIX_CONFIG_FIREWALL_ENABLE=1") 381endif() 382 383option(OT_FULL_LOGS "enable full logs") 384if(OT_FULL_LOGS) 385 if(NOT OT_LOG_LEVEL) 386 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG") 387 endif() 388 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1") 389endif() 390 391option(OT_OTNS "enable OTNS support") 392if(OT_OTNS) 393 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_OTNS_ENABLE=1") 394endif() 395 396set(OT_RCP_RESTORATION_MAX_COUNT "0" CACHE STRING "set max RCP restoration count") 397if(OT_RCP_RESTORATION_MAX_COUNT MATCHES "^[0-9]+$") 398 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT=${OT_RCP_RESTORATION_MAX_COUNT}") 399else() 400 message(FATAL_ERROR "Invalid max RCP restoration count: ${OT_RCP_RESTORATION_MAX_COUNT}") 401endif() 402 403option(OT_EXCLUDE_TCPLP_LIB "exclude TCPlp library from build") 404 405# Checks 406if(OT_PLATFORM_UDP AND OT_UDP_FORWARD) 407 message(FATAL_ERROR "OT_PLATFORM_UDP and OT_UDP_FORWARD are exclusive") 408endif() 409