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_ASSERT "enable assert function OT_ASSERT()" ON) 38if(OT_ASSERT) 39 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=1") 40else() 41 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=0") 42endif() 43 44option(OT_BACKBONE_ROUTER "enable backbone router functionality") 45if(OT_BACKBONE_ROUTER) 46 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1") 47 set(OT_BACKBONE_ROUTER_DUA_NDPROXYING ON CACHE BOOL "Enable DUA NDProxying by default") 48 set(OT_BACKBONE_ROUTER_MULTICAST_ROUTING ON CACHE BOOL "Enable Multicast Routing by default") 49endif() 50 51option(OT_BACKBONE_ROUTER_DUA_NDPROXYING "enable Backbone Router DUA ND Proxying functionality" OFF) 52if(OT_BACKBONE_ROUTER_DUA_NDPROXYING) 53 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=1") 54else() 55 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=0") 56endif() 57 58option(OT_BACKBONE_ROUTER_MULTICAST_ROUTING "enable Backbone Router Multicast Routing functionality" OFF) 59if(OT_BACKBONE_ROUTER_MULTICAST_ROUTING) 60 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=1") 61else() 62 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=0") 63endif() 64 65option(OT_BORDER_AGENT "enable border agent support") 66if(OT_BORDER_AGENT) 67 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1") 68endif() 69 70option(OT_BORDER_ROUTER "enable border router support") 71if(OT_BORDER_ROUTER) 72 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1") 73endif() 74 75option(OT_BORDER_ROUTING "enable border routing support") 76if(OT_BORDER_ROUTING) 77 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1") 78endif() 79 80if(NOT OT_EXTERNAL_MBEDTLS) 81 set(OT_MBEDTLS mbedtls) 82 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=1") 83else() 84 set(OT_MBEDTLS ${OT_EXTERNAL_MBEDTLS}) 85 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=0") 86endif() 87 88option(OT_BUILTIN_MBEDTLS_MANAGEMENT "enable builtin mbedtls management" ON) 89if(OT_BUILTIN_MBEDTLS_MANAGEMENT) 90 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=1") 91else() 92 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=0") 93endif() 94 95option(OT_CHANNEL_MANAGER "enable channel manager support") 96if(OT_CHANNEL_MANAGER) 97 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1") 98endif() 99 100option(OT_CHANNEL_MONITOR "enable channel monitor support") 101if(OT_CHANNEL_MONITOR) 102 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1") 103endif() 104 105option(OT_CHILD_SUPERVISION "enable child supervision support") 106if(OT_CHILD_SUPERVISION) 107 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1") 108endif() 109 110option(OT_COAP "enable coap api support") 111if(OT_COAP) 112 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_API_ENABLE=1") 113endif() 114 115option(OT_COAPS "enable secure coap api support") 116if(OT_COAPS) 117 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1") 118endif() 119 120option(OT_COAP_BLOCK "enable coap block-wise transfer (RFC7959) api support") 121if(OT_COAP_BLOCK) 122 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE=1") 123endif() 124 125option(OT_COAP_OBSERVE "enable coap observe (RFC7641) api support") 126if(OT_COAP_OBSERVE) 127 list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE=1") 128endif() 129 130option(OT_COMMISSIONER "enable commissioner support") 131if(OT_COMMISSIONER) 132 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1") 133endif() 134 135option(OT_CSL_RECEIVER "enable csl receiver") 136if(OT_CSL_RECEIVER) 137 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1") 138endif() 139 140option(OT_CSL_AUTO_SYNC "enable data polling based on csl config" ${OT_CSL_RECEIVER}) 141if(OT_CSL_AUTO_SYNC) 142 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=1") 143else() 144 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=0") 145endif() 146 147option(OT_CSL_DEBUG "enable csl debug") 148if(OT_CSL_DEBUG) 149 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE=1") 150endif() 151 152option(OT_DATASET_UPDATER "enable dataset updater support") 153if(OT_DATASET_UPDATER) 154 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1") 155endif() 156 157option(OT_DHCP6_CLIENT "enable DHCP6 client support") 158if(OT_DHCP6_CLIENT) 159 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1") 160endif() 161 162option(OT_DHCP6_SERVER "enable DHCP6 server support") 163if(OT_DHCP6_SERVER) 164 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1") 165endif() 166 167option(OT_DIAGNOSTIC "enable diagnostic support") 168if(OT_DIAGNOSTIC) 169 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DIAG_ENABLE=1") 170endif() 171 172option(OT_DNS_CLIENT "enable DNS client support") 173if(OT_DNS_CLIENT) 174 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1") 175endif() 176 177option(OT_DNSSD_SERVER "enable DNS-SD server support") 178if(OT_DNSSD_SERVER) 179 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE=1") 180endif() 181 182option(OT_DOC "Build OpenThread documentation") 183 184option(OT_ECDSA "enable ECDSA support") 185if(OT_ECDSA) 186 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ECDSA_ENABLE=1") 187endif() 188 189option(OT_SRP_CLIENT "enable SRP client support") 190if (OT_SRP_CLIENT) 191 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1") 192endif() 193 194option(OT_DUA "enable Domain Unicast Address feature for Thread 1.2") 195if(OT_DUA) 196 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DUA_ENABLE=1") 197endif() 198 199option(OT_MESSAGE_USE_HEAP "enable heap allocator for message buffers") 200if(OT_MESSAGE_USE_HEAP) 201 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1") 202endif() 203 204option(OT_MLR "enable Multicast Listener Registration feature for Thread 1.2") 205if(OT_MLR) 206 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLR_ENABLE=1") 207endif() 208 209option(OT_EXTERNAL_HEAP "enable external heap support") 210if(OT_EXTERNAL_HEAP) 211 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1") 212endif() 213 214option(OT_HISTORY_TRACKER "enable history tracker support") 215if(OT_HISTORY_TRACKER) 216 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE=1") 217endif() 218 219option(OT_IP6_FRAGM "enable ipv6 fragmentation support") 220if(OT_IP6_FRAGM) 221 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1") 222endif() 223 224option(OT_JAM_DETECTION "enable jam detection support") 225if(OT_JAM_DETECTION) 226 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1") 227endif() 228 229option(OT_JOINER "enable joiner support") 230if(OT_JOINER) 231 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JOINER_ENABLE=1") 232endif() 233 234option(OT_LEGACY "enable legacy network support") 235if(OT_LEGACY) 236 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LEGACY_ENABLE=1") 237endif() 238 239option(OT_LINK_RAW "enable link raw service") 240if(OT_LINK_RAW) 241 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LINK_RAW_ENABLE=1") 242endif() 243 244option(OT_LINK_METRICS_INITIATOR "enable link metrics initiator") 245if (OT_LINK_METRICS_INITIATOR) 246 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE=1") 247endif() 248 249option(OT_LINK_METRICS_SUBJECT "enable link metrics subject") 250if (OT_LINK_METRICS_SUBJECT) 251 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE=1") 252endif() 253 254option(OT_LOG_LEVEL_DYNAMIC "enable dynamic log level control") 255if(OT_LOG_LEVEL_DYNAMIC) 256 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1") 257endif() 258 259option(OT_MAC_FILTER "enable mac filter support") 260if(OT_MAC_FILTER) 261 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1") 262endif() 263 264option(OT_MLE_LONG_ROUTES "enable MLE long routes extension (experimental, breaks Thread conformance)") 265if(OT_MLE_LONG_ROUTES) 266 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE=1") 267endif() 268 269option(OT_MTD_NETDIAG "enable TMF network diagnostics on MTDs") 270if(OT_MTD_NETDIAG) 271 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1") 272endif() 273 274option(OT_MULTIPLE_INSTANCE "enable multiple instances") 275if(OT_MULTIPLE_INSTANCE) 276 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE=1") 277endif() 278 279option(OT_NEIGHBOR_DISCOVERY_AGENT "enable neighbor discovery agent support") 280if(OT_NEIGHBOR_DISCOVERY_AGENT) 281 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE=1") 282endif() 283 284option(OT_NETDATA_PUBLISHER "enable Thread Network Data publisher") 285if(OT_NETDATA_PUBLISHER) 286 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE=1") 287endif() 288 289option(OT_PING_SENDER "enable ping sender support" ${OT_APP_CLI}) 290if(OT_PING_SENDER) 291 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PING_SENDER_ENABLE=1") 292endif() 293 294option(OT_PLATFORM_NETIF "enable platform netif support") 295if(OT_PLATFORM_NETIF) 296 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1") 297endif() 298 299option(OT_PLATFORM_UDP "enable platform UDP support") 300if(OT_PLATFORM_UDP) 301 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1") 302endif() 303 304if(OT_POSIX_SETTINGS_PATH) 305 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH=${OT_POSIX_SETTINGS_PATH}") 306endif() 307 308option(OT_REFERENCE_DEVICE "enable Thread Test Harness reference device support") 309if(OT_REFERENCE_DEVICE) 310 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1") 311endif() 312 313option(OT_SERVICE "enable support for injecting Service entries into the Thread Network Data") 314if(OT_SERVICE) 315 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1") 316endif() 317 318option(OT_SETTINGS_RAM "enable volatile-only storage of settings") 319if(OT_SETTINGS_RAM) 320 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SETTINGS_RAM=1") 321endif() 322 323option(OT_SLAAC "enable support for adding of auto-configured SLAAC addresses by OpenThread") 324if(OT_SLAAC) 325 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1") 326endif() 327 328option(OT_SNTP_CLIENT "enable SNTP Client support") 329if(OT_SNTP_CLIENT) 330 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1") 331endif() 332 333option(OT_SRP_SERVER "enable SRP server") 334if (OT_SRP_SERVER) 335 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SRP_SERVER_ENABLE=1") 336endif() 337 338option(OT_TIME_SYNC "enable the time synchronization service feature") 339if(OT_TIME_SYNC) 340 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1") 341endif() 342 343option(OT_TREL "enable TREL radio link for Thread over Infrastructure feature") 344if (OT_TREL) 345 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1") 346endif() 347 348option(OT_UDP_FORWARD "enable UDP forward support") 349if(OT_UDP_FORWARD) 350 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1") 351endif() 352 353option(OT_FULL_LOGS "enable full logs") 354if(OT_FULL_LOGS) 355 if(NOT OT_LOG_LEVEL) 356 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG") 357 endif() 358 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1") 359 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_REGION=1") 360endif() 361 362option(OT_OTNS "enable OTNS support") 363if(OT_OTNS) 364 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_OTNS_ENABLE=1") 365endif() 366 367set(OT_RCP_RESTORATION_MAX_COUNT "0" CACHE STRING "set max RCP restoration count") 368if(OT_RCP_RESTORATION_MAX_COUNT MATCHES "^[0-9]+$") 369 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT=${OT_RCP_RESTORATION_MAX_COUNT}") 370else() 371 message(FATAL_ERROR "Invalid max RCP restoration count: ${OT_RCP_RESTORATION_MAX_COUNT}") 372endif() 373 374# Checks 375if(OT_PLATFORM_UDP AND OT_UDP_FORWARD) 376 message(FATAL_ERROR "OT_PLATFORM_UDP and OT_UDP_FORWARD are exclusive") 377endif() 378