1if(CONFIG_OPENTHREAD) 2if(CONFIG_OPENTHREAD_SOURCES) 3 4set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 6# OpenThread options 7set(OT_BUILD_EXECUTABLES OFF CACHE BOOL "Disable OpenThread samples") 8set(OT_BUILTIN_MBEDTLS_MANAGEMENT OFF CACHE BOOL "Use Zephyr's mbedTLS heap") 9set(OT_PLATFORM "zephyr" CACHE STRING "Zephyr as a target platform") 10set(OT_THREAD_VERSION ${CONFIG_OPENTHREAD_THREAD_VERSION} CACHE STRING "User selected Thread stack version") 11set(OT_CLI_TRANSPORT "CONSOLE" CACHE STRING "Set CLI to use console interpreter") 12 13string(REPLACE " " ";" OT_MBEDTLS_LIB_LIST " ${CONFIG_OPENTHREAD_MBEDTLS_LIB_NAME}") 14 15set( 16 OT_EXTERNAL_MBEDTLS 17 ${OT_MBEDTLS_LIB_LIST} 18 CACHE STRING 19 "Specify external mbedtls library" 20 FORCE 21) 22 23if(CONFIG_OPENTHREAD_FTD) 24 set(OT_FTD ON CACHE BOOL "Enable FTD" FORCE) 25 set(OT_MTD OFF CACHE BOOL "Enable MTD" FORCE) 26elseif(CONFIG_OPENTHREAD_MTD) 27 set(OT_FTD OFF CACHE BOOL "Enable FTD" FORCE) 28 set(OT_MTD ON CACHE BOOL "Enable MTD" FORCE) 29endif() 30 31if(CONFIG_OPENTHREAD_ANYCAST_LOCATOR) 32 set(OT_ANYCAST_LOCATOR ON CACHE BOOL "Enable anycast locator" FORCE) 33else() 34 set(OT_ANYCAST_LOCATOR OFF CACHE BOOL "Enable anycast locator" FORCE) 35endif() 36 37if(CONFIG_ASSERT) 38 set(OT_ASSERT ON CACHE BOOL "Enable assert function OT_ASSERT()" FORCE) 39else() 40 set(OT_ASSERT OFF CACHE BOOL "Enable assert function OT_ASSERT()" FORCE) 41endif() 42 43if(CONFIG_OPENTHREAD_BACKBONE_ROUTER) 44 set(OT_BACKBONE_ROUTER ON CACHE BOOL "Enable backbone router functionality" FORCE) 45else() 46 set(OT_BACKBONE_ROUTER OFF CACHE BOOL "Enable backbone router functionality" FORCE) 47endif() 48 49if(CONFIG_OPENTHREAD_BACKBONE_ROUTER_DUA_NDPROXYING) 50 set(OT_BACKBONE_ROUTER_DUA_NDPROXYING ON CACHE BOOL "Enable BBR DUA ND Proxy support" FORCE) 51else() 52 set(OT_BACKBONE_ROUTER_DUA_NDPROXYING OFF CACHE BOOL "Enable BBR DUA ND Proxy support" FORCE) 53endif() 54 55if(CONFIG_OPENTHREAD_BACKBONE_ROUTER_MULTICAST_ROUTING) 56 set(OT_BACKBONE_ROUTER_MULTICAST_ROUTING ON CACHE BOOL "Enable BBR MR support" FORCE) 57else() 58 set(OT_BACKBONE_ROUTER_MULTICAST_ROUTING OFF CACHE BOOL "Enable BBR MR support" FORCE) 59endif() 60 61if(CONFIG_OPENTHREAD_BORDER_AGENT) 62 set(OT_BORDER_AGENT ON CACHE BOOL "Enable Border Agent" FORCE) 63else() 64 set(OT_BORDER_AGENT OFF CACHE BOOL "Enable Border Agent" FORCE) 65endif() 66 67if(CONFIG_OPENTHREAD_BORDER_ROUTER) 68 set(OT_BORDER_ROUTER ON CACHE BOOL "Enable Border Router" FORCE) 69else() 70 set(OT_BORDER_ROUTER OFF CACHE BOOL "Enable Border Router" FORCE) 71endif() 72 73if(CONFIG_OPENTHREAD_BORDER_ROUTING) 74 set(OT_BORDER_ROUTING ON CACHE BOOL "Enable Border routing" FORCE) 75else() 76 set(OT_BORDER_ROUTING OFF CACHE BOOL "Enable Border routing" FORCE) 77endif() 78 79if(CONFIG_OPENTHREAD_BORDER_ROUTING_COUNTERS) 80 set(OT_BORDER_ROUTING_COUNTERS ON CACHE BOOL "Enable Border routing counters" FORCE) 81else() 82 set(OT_BORDER_ROUTING_COUNTERS OFF CACHE BOOL "Enable Border routing counters" FORCE) 83endif() 84 85if(CONFIG_OPENTHREAD_CHANNEL_MANAGER) 86 set(OT_CHANNEL_MANAGER ON CACHE BOOL "Enable channel manager support" FORCE) 87else() 88 set(OT_CHANNEL_MANAGER OFF CACHE BOOL "Enable channel manager support" FORCE) 89endif() 90 91if(CONFIG_OPENTHREAD_CHANNEL_MONITOR) 92 set(OT_CHANNEL_MONITOR ON CACHE BOOL "Enable channel monitor support" FORCE) 93else() 94 set(OT_CHANNEL_MONITOR OFF CACHE BOOL "Enable channel monitor support" FORCE) 95endif() 96 97if(CONFIG_OPENTHREAD_COAP) 98 set(OT_COAP ON CACHE BOOL "Enable CoAP API" FORCE) 99else() 100 set(OT_COAP OFF CACHE BOOL "Enable CoAP API" FORCE) 101endif() 102 103if(CONFIG_OPENTHREAD_COAP_BLOCK) 104 set(OT_COAP_BLOCK ON CACHE BOOL "Enable CoAP Block-wise option support" FORCE) 105else() 106 set(OT_COAP_BLOCK OFF CACHE BOOL "Enable CoAP Block-wise option support" FORCE) 107endif() 108 109if(CONFIG_OPENTHREAD_COAP_OBSERVE) 110 set(OT_COAP_OBSERVE ON CACHE BOOL "Enable CoAP Observe option support" FORCE) 111else() 112 set(OT_COAP_OBSERVE OFF CACHE BOOL "Enable CoAP Observe option support" FORCE) 113endif() 114 115if(CONFIG_OPENTHREAD_COAPS) 116 set(OT_COAPS ON CACHE BOOL "Enable secure CoAP API support" FORCE) 117else() 118 set(OT_COAPS OFF CACHE BOOL "Enable secure CoAP API support" FORCE) 119endif() 120 121if(CONFIG_OPENTHREAD_COMMISSIONER) 122 set(OT_COMMISSIONER ON CACHE BOOL "Enable Commissioner" FORCE) 123else() 124 set(OT_COMMISSIONER OFF CACHE BOOL "Enable Commissioner" FORCE) 125endif() 126 127if(CONFIG_OPENTHREAD_CSL_AUTO_SYNC) 128 set(OT_CSL_AUTO_SYNC ON CACHE BOOL "Enable csl autosync" FORCE) 129else() 130 set(OT_CSL_AUTO_SYNC OFF CACHE BOOL "Enable csl autosync" FORCE) 131endif() 132 133if(CONFIG_OPENTHREAD_CSL_DEBUG) 134 set(OT_CSL_DEBUG ON CACHE BOOL "Enable CSL debug" FORCE) 135else() 136 set(OT_CSL_DEBUG OFF CACHE BOOL "Enable CSL debug" FORCE) 137endif() 138 139if(CONFIG_OPENTHREAD_CSL_RECEIVER) 140 set(OT_CSL_RECEIVER ON CACHE BOOL "Enable CSL receiver feature for Thread 1.2" FORCE) 141else() 142 set(OT_CSL_RECEIVER OFF CACHE BOOL "Enable CSL receiver feature for Thread 1.2" FORCE) 143endif() 144 145if(CONFIG_OPENTHREAD_DATASET_UPDATER) 146 set(OT_DATASET_UPDATER ON CACHE BOOL "Enable Dataset updater" FORCE) 147else() 148 set(OT_DATASET_UPDATER OFF CACHE BOOL "Enable Dataset updater" FORCE) 149endif() 150 151if(CONFIG_OPENTHREAD_DHCP6_CLIENT) 152 set(OT_DHCP6_CLIENT ON CACHE BOOL "Enable DHCPv6 Client" FORCE) 153else() 154 set(OT_DHCP6_CLIENT OFF CACHE BOOL "Enable DHCPv6 Client" FORCE) 155endif() 156 157if(CONFIG_OPENTHREAD_DHCP6_SERVER) 158 set(OT_DHCP6_SERVER ON CACHE BOOL "Enable DHCPv6 Server" FORCE) 159else() 160 set(OT_DHCP6_SERVER OFF CACHE BOOL "Enable DHCPv6 Server" FORCE) 161endif() 162 163if(CONFIG_OPENTHREAD_DIAG) 164 set(OT_DIAGNOSTIC ON CACHE BOOL "Enable Diagnostics support" FORCE) 165else() 166 set(OT_DIAGNOSTIC OFF CACHE BOOL "Enable Diagnostics support" FORCE) 167endif() 168 169if(CONFIG_OPENTHREAD_DNS_CLIENT) 170 set(OT_DNS_CLIENT ON CACHE BOOL "Enable DNS client support" FORCE) 171else() 172 set(OT_DNS_CLIENT OFF CACHE BOOL "Enable DNS client support" FORCE) 173endif() 174 175if(CONFIG_OPENTHREAD_DNS_CLIENT_OVER_TCP) 176 set(OT_DNS_CLIENT_OVER_TCP ON CACHE BOOL "Enable dns query over tcp" FORCE) 177else() 178 set(OT_DNS_CLIENT_OVER_TCP OFF CACHE BOOL "Enable dns query over tcp" FORCE) 179endif() 180 181if(CONFIG_OPENTHREAD_DNS_DSO) 182 set(OT_DNS_DSO ON CACHE BOOL "Enable DNS Stateful Operations (DSO) support" FORCE) 183else() 184 set(OT_DNS_DSO OFF CACHE BOOL "Enable DNS Stateful Operations (DSO) support" FORCE) 185endif() 186 187if(CONFIG_OPENTHREAD_DNS_UPSTREAM_QUERY) 188 set(OT_DNS_UPSTREAM_QUERY ON CACHE BOOL "Enable forwarding DNS queries to upstream" FORCE) 189else() 190 set(OT_DNS_UPSTREAM_QUERY OFF CACHE BOOL "Enable forwarding DNS queries to upstream" FORCE) 191endif() 192 193if(CONFIG_OPENTHREAD_DNSSD_SERVER) 194 set(OT_DNSSD_SERVER ON CACHE BOOL "Enable DNS-SD server support" FORCE) 195else() 196 set(OT_DNSSD_SERVER OFF CACHE BOOL "Enable DNS-SD server support" FORCE) 197endif() 198 199if(CONFIG_OPENTHREAD_DUA) 200 set(OT_DUA ON CACHE BOOL "Enable Domain Unicast Address feature for Thread 1.2" FORCE) 201else() 202 set(OT_DUA OFF CACHE BOOL "Enable Domain Unicast Address feature for Thread 1.2" FORCE) 203endif() 204 205if(CONFIG_OPENTHREAD_ECDSA) 206 set(OT_ECDSA ON CACHE BOOL "Enable ECDSA support" FORCE) 207else() 208 set(OT_ECDSA OFF CACHE BOOL "Enable ECDSA support" FORCE) 209endif() 210 211if(CONFIG_OPENTHREAD_ENABLE_SERVICE) 212 set(OT_SERVICE ON CACHE BOOL "Enable Service entries in Thread Network Data" FORCE) 213else() 214 set(OT_SERVICE OFF CACHE BOOL "Enable Service entries in Thread Network Data" FORCE) 215endif() 216 217if(CONFIG_OPENTHREAD_EXTERNAL_HEAP) 218 set(OT_EXTERNAL_HEAP ON CACHE BOOL "Enable external heap support" FORCE) 219else() 220 set(OT_EXTERNAL_HEAP OFF CACHE BOOL "Enable external heap support" FORCE) 221endif() 222 223if(CONFIG_OPENTHREAD_FIREWALL) 224 set(OT_FIREWALL ON CACHE BOOL "Enable firewall" FORCE) 225else() 226 set(OT_FIREWALL OFF CACHE BOOL "Enable firewall" FORCE) 227endif() 228 229if(CONFIG_OPENTHREAD_FULL_LOGS) 230 set(OT_FULL_LOGS ON CACHE BOOL "Enable full logs" FORCE) 231else() 232 set(OT_FULL_LOGS OFF CACHE BOOL "Enable full logs" FORCE) 233endif() 234 235if(CONFIG_OPENTHREAD_HISTORY_TRACKER) 236 set(OT_HISTORY_TRACKER ON CACHE BOOL "Enable history tracker support." FORCE) 237else() 238 set(OT_HISTORY_TRACKER OFF CACHE BOOL "Enable history tracker support." FORCE) 239endif() 240 241if(CONFIG_OPENTHREAD_IP6_FRAGM) 242 set(OT_IP6_FRAGM ON CACHE BOOL "Enable IPv6 fragmentation support" FORCE) 243else() 244 set(OT_IP6_FRAGM OFF CACHE BOOL "Enable IPv6 fragmentation support" FORCE) 245endif() 246 247if(CONFIG_OPENTHREAD_JAM_DETECTION) 248 set(OT_JAM_DETECTION ON CACHE BOOL "Enable Jam Detection" FORCE) 249else() 250 set(OT_JAM_DETECTION OFF CACHE BOOL "Enable Jam Detection" FORCE) 251endif() 252 253if(CONFIG_OPENTHREAD_JOINER) 254 set(OT_JOINER ON CACHE BOOL "Enable Joiner" FORCE) 255else() 256 set(OT_JOINER OFF CACHE BOOL "Enable Joiner" FORCE) 257endif() 258 259if(CONFIG_OPENTHREAD_LEGACY) 260 set(OT_LEGACY ON CACHE BOOL "Enable legacy network support" FORCE) 261else() 262 set(OT_LEGACY OFF CACHE BOOL "Enable legacy network support" FORCE) 263endif() 264 265if(CONFIG_OPENTHREAD_LINK_METRICS_INITIATOR) 266 set(OT_LINK_METRICS_INITIATOR ON CACHE BOOL "Enable Link Metrics initiator for Thread 1.2" FORCE) 267else() 268 set(OT_LINK_METRICS_INITIATOR OFF CACHE BOOL "Enable Link Metrics initiator for Thread 1.2" FORCE) 269endif() 270 271if(CONFIG_OPENTHREAD_LINK_METRICS_SUBJECT) 272 set(OT_LINK_METRICS_SUBJECT ON CACHE BOOL "Enable Link Metrics subject for Thread 1.2" FORCE) 273else() 274 set(OT_LINK_METRICS_SUBJECT OFF CACHE BOOL "Enable Link Metrics subject for Thread 1.2" FORCE) 275endif() 276 277if(CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC) 278 set(OT_LOG_LEVEL_DYNAMIC ON CACHE BOOL "Enable dynamic log level control" FORCE) 279else() 280 set(OT_LOG_LEVEL_DYNAMIC OFF CACHE BOOL "Enable dynamic log level control" FORCE) 281endif() 282 283if(CONFIG_OPENTHREAD_MAC_FILTER) 284 set(OT_MAC_FILTER ON CACHE BOOL "Enable MAC filter support" FORCE) 285else() 286 set(OT_MAC_FILTER OFF CACHE BOOL "Enable MAC filter support" FORCE) 287endif() 288 289if(CONFIG_OPENTHREAD_MESH_DIAG) 290 set(OT_MESH_DIAG ON CACHE BOOL "Enable Mesh Diagnostics" FORCE) 291else() 292 set(OT_MESH_DIAG OFF CACHE BOOL "Enable Mesh Diagnostics" FORCE) 293endif() 294 295if(CONFIG_OPENTHREAD_MESSAGE_USE_HEAP) 296 set(OT_MESSAGE_USE_HEAP ON CACHE BOOL "Enable heap allocator for message buffers" FORCE) 297else() 298 set(OT_MESSAGE_USE_HEAP OFF CACHE BOOL "Enable heap allocator for message buffers" FORCE) 299endif() 300 301if(CONFIG_OPENTHREAD_MLE_LONG_ROUTES) 302 set(OT_MLE_LONG_ROUTES ON CACHE BOOL "Enable MLE long routes support (Experimental)" FORCE) 303else() 304 set(OT_MLE_LONG_ROUTES OFF CACHE BOOL "Enable MLE long routes support (Experimental)" FORCE) 305endif() 306 307if(CONFIG_OPENTHREAD_MLR) 308 set(OT_MLR ON CACHE BOOL "Enable Multicast Listener Registration feature for Thread 1.2" FORCE) 309else() 310 set(OT_MLR OFF CACHE BOOL "Enable Multicast Listener Registration feature for Thread 1.2" FORCE) 311endif() 312 313if(CONFIG_OPENTHREAD_MULTIPLE_INSTANCE) 314 set(OT_MULTIPLE_INSTANCE ON CACHE BOOL "Enable multiple instances" FORCE) 315else() 316 set(OT_MULTIPLE_INSTANCE OFF CACHE BOOL "Enable multiple instances" FORCE) 317endif() 318 319if(CONFIG_OPENTHREAD_NAT64_BORDER_ROUTING) 320 set(OT_NAT64_BORDER_ROUTING ON CACHE BOOL "Enable border routing NAT64 support" FORCE) 321else() 322 set(OT_NAT64_BORDER_ROUTING OFF CACHE BOOL "Enable border routing NAT64 support" FORCE) 323endif() 324 325if(CONFIG_OPENTHREAD_NAT64_TRANSLATOR) 326 set(OT_NAT64_TRANSLATOR ON CACHE BOOL "Enable NAT64 translator" FORCE) 327else() 328 set(OT_NAT64_TRANSLATOR OFF CACHE BOOL "Enable NAT64 translator" FORCE) 329endif() 330 331if(CONFIG_OPENTHREAD_NEIGHBOR_DISCOVERY_AGENT) 332 set(OT_NEIGHBOR_DISCOVERY_AGENT ON CACHE BOOL "Enable neighbor discovery agent support" FORCE) 333else() 334 set(OT_NEIGHBOR_DISCOVERY_AGENT OFF CACHE BOOL "Enable neighbor discovery agent support" FORCE) 335endif() 336 337if(CONFIG_OPENTHREAD_NETDIAG_CLIENT) 338 set(OT_NETDIAG_CLIENT ON CACHE BOOL "Enable TMF network diagnostics on clients" FORCE) 339else() 340 set(OT_NETDIAG_CLIENT OFF CACHE BOOL "Enable TMF network diagnostics on clients" FORCE) 341endif() 342 343if(CONFIG_OPENTHREAD_NETDATA_PUBLISHER) 344 set(OT_NETDATA_PUBLISHER ON CACHE BOOL "Enable Thread Network Data publisher" FORCE) 345else() 346 set(OT_NETDATA_PUBLISHER OFF CACHE BOOL "Enable Thread Network Data publisher" FORCE) 347endif() 348 349if(CONFIG_OPENTHREAD_OTNS) 350 set(OT_OTNS ON CACHE BOOL "Enable OTNS support" FORCE) 351else() 352 set(OT_OTNS OFF CACHE BOOL "Enable OTNS support" FORCE) 353endif() 354 355if(CONFIG_OPENTHREAD_PING_SENDER) 356 set(OT_PING_SENDER ON CACHE BOOL "Enable ping sender support" FORCE) 357else() 358 set(OT_PING_SENDER OFF CACHE BOOL "Enable ping sender support" FORCE) 359endif() 360 361if(CONFIG_OPENTHREAD_PLATFORM_NETIF) 362 set(OT_PLATFORM_NETIF ON CACHE BOOL "Enable platform netif support" FORCE) 363else() 364 set(OT_PLATFORM_NETIF OFF CACHE BOOL "Enable platform netif support" FORCE) 365endif() 366 367if(CONFIG_OPENTHREAD_PLATFORM_UDP) 368 set(OT_PLATFORM_UDP ON CACHE BOOL "Enable platform UDP support" FORCE) 369else() 370 set(OT_PLATFORM_UDP OFF CACHE BOOL "Enable platform UDP support" FORCE) 371endif() 372 373if(CONFIG_OPENTHREAD_POWER_SUPPLY) 374 set(OT_POWER_SUPPLY ${CONFIG_OPENTHREAD_POWER_SUPPLY} CACHE STRING "Power supply configuration" FORCE) 375endif() 376 377if(CONFIG_OPENTHREAD_RADIO_LINK_IEEE_802_15_4_ENABLE) 378 set(OT_15_4 ON CACHE BOOL "Enable 802.15.4 radio" FORCE) 379else() 380 set(OT_15_4 OFF CACHE BOOL "Enable 802.15.4 radio" FORCE) 381endif() 382 383if(CONFIG_OPENTHREAD_RAW) 384 set(OT_LINK_RAW ON CACHE BOOL "Enable Link Raw" FORCE) 385else() 386 set(OT_LINK_RAW OFF CACHE BOOL "Enable Link Raw" FORCE) 387endif() 388 389if(CONFIG_OPENTHREAD_REFERENCE_DEVICE) 390 set(OT_REFERENCE_DEVICE ON CACHE BOOL "Enable Thread Certification Reference Device" FORCE) 391else() 392 set(OT_REFERENCE_DEVICE OFF CACHE BOOL "Enable Thread Certification Reference Device" FORCE) 393endif() 394 395if(CONFIG_OPENTHREAD_SETTINGS_RAM) 396 set(OT_SETTINGS_RAM ON CACHE BOOL "Enable volatile-only storage of settings" FORCE) 397else() 398 set(OT_SETTINGS_RAM OFF CACHE BOOL "Enable volatile-only storage of settings" FORCE) 399endif() 400 401if(CONFIG_OPENTHREAD_SLAAC) 402 set(OT_SLAAC ON CACHE BOOL "Enable SLAAC" FORCE) 403else() 404 set(OT_SLAAC OFF CACHE BOOL "Enable SLAAC" FORCE) 405endif() 406 407if(CONFIG_OPENTHREAD_SNTP_CLIENT) 408 set(OT_SNTP_CLIENT ON CACHE BOOL "Enable SNTP Client support" FORCE) 409else() 410 set(OT_SNTP_CLIENT OFF CACHE BOOL "Enable SNTP Client support" FORCE) 411endif() 412 413if(CONFIG_OPENTHREAD_SRP_CLIENT) 414 set(OT_SRP_CLIENT ON CACHE BOOL "Enable SRP Client support" FORCE) 415else() 416 set(OT_SRP_CLIENT OFF CACHE BOOL "Enable SRP Client support" FORCE) 417endif() 418 419if(CONFIG_OPENTHREAD_SRP_SERVER) 420 set(OT_SRP_SERVER ON CACHE BOOL "Enable SRP Server support" FORCE) 421else() 422 set(OT_SRP_SERVER OFF CACHE BOOL "Enable SRP Server support" FORCE) 423endif() 424 425if(CONFIG_OPENTHREAD_TCP_ENABLE) 426 set(OT_TCP ON CACHE BOOL "Enable TCP support" FORCE) 427else() 428 set(OT_TCP OFF CACHE BOOL "Enable TCP support" FORCE) 429endif() 430 431if(CONFIG_OPENTHREAD_TIME_SYNC) 432 set(OT_TIME_SYNC ON CACHE BOOL "Enable the time synchronization service feature" FORCE) 433else() 434 set(OT_TIME_SYNC OFF CACHE BOOL "Enable the time synchronization service feature" FORCE) 435endif() 436 437if(CONFIG_OPENTHREAD_TREL) 438 set(OT_TREL ON CACHE BOOL "Enable TREL radio link for Thread over Infrastructure feature" FORCE) 439else() 440 set(OT_TREL OFF CACHE BOOL "Enable TREL radio link for Thread over Infrastructure feature" FORCE) 441endif() 442 443if(CONFIG_OPENTHREAD_TX_BEACON_PAYLOAD) 444 set(OT_TX_BEACON_PAYLOAD ON CACHE BOOL "Enable tx beacon payload support" FORCE) 445else() 446 set(OT_TX_BEACON_PAYLOAD OFF CACHE BOOL "Enable tx beacon payload support" FORCE) 447endif() 448 449if(CONFIG_OPENTHREAD_UDP_FORWARD) 450 set(OT_UDP_FORWARD ON CACHE BOOL "Enable UDP forward feature" FORCE) 451else() 452 set(OT_UDP_FORWARD OFF CACHE BOOL "Enable UDP forward feature" FORCE) 453endif() 454 455if(CONFIG_OPENTHREAD_UPTIME) 456 set(OT_UPTIME ON CACHE BOOL "Enable support for tracking OpenThread instance's uptime" FORCE) 457else() 458 set(OT_UPTIME OFF CACHE BOOL "Enable support for tracking OpenThread instance's uptime" FORCE) 459endif() 460 461if(CONFIG_OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE) 462 set(OT_NCP_VENDOR_HOOK_SOURCE ${CONFIG_OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE} CACHE STRING "NCP vendor hook source file name" FORCE) 463endif() 464 465set(BUILD_TESTING OFF CACHE BOOL "Disable openthread cmake testing targets" FORCE) 466 467# Zephyr logging options 468 469if(CONFIG_LOG_BACKEND_SPINEL) 470 add_definitions( 471 -DOPENTHREAD_CONFIG_LOG_OUTPUT=OPENTHREAD_CONFIG_LOG_OUTPUT_APP 472 ) 473endif() 474 475# Other options 476add_definitions( 477 -DOPENTHREAD_CONFIG_LOG_LEVEL=${CONFIG_OPENTHREAD_LOG_LEVEL} 478 -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-zephyr-config.h" 479) 480 481# Need to specify build directory as well 482add_subdirectory(${ZEPHYR_CURRENT_MODULE_DIR} build) 483 484zephyr_get_targets(${ZEPHYR_CURRENT_MODULE_DIR} "STATIC_LIBRARY;OBJECT_LIBRARY" ALL_TARGETS) 485foreach(target ${ALL_TARGETS}) 486 # We don't want to build all openthread libraries per default. 487 # Setting EXCLUDE_FROM_ALL ensures that only libraries that are linked 488 # into Zephyr will be built due to dependencies. 489 set_property(TARGET ${target} PROPERTY EXCLUDE_FROM_ALL TRUE) 490endforeach() 491 492string(REPLACE " " ";" OT_PARAM_LIST " ${CONFIG_OPENTHREAD_CUSTOM_PARAMETERS}") 493target_compile_definitions(ot-config INTERFACE ${OT_PARAM_LIST}) 494 495# Zephyr compiler options 496target_include_directories(ot-config INTERFACE 497 $<TARGET_PROPERTY:zephyr_interface,INTERFACE_INCLUDE_DIRECTORIES> 498) 499 500target_include_directories(ot-config SYSTEM INTERFACE 501 $<TARGET_PROPERTY:zephyr_interface,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES> 502) 503 504target_compile_definitions(ot-config INTERFACE 505 $<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_DEFINITIONS> 506) 507 508# Openthread can use minimal libc, which requires autoconf.h 509# (specifically CONFIG_ARM and friends). autoconf.h can't be included 510# through openthread-*-config.h because openthread third-party 511# libraries do not include this header. So we add the defines to all 512# OpenThread files through the gcc flag -imacros instead. 513target_compile_options(ot-config INTERFACE 514 $<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS> -fno-builtin 515 -imacros ${AUTOCONF_H} 516) 517 518# Openthread depends on errno.h, which includes errno_private.h in minimal libc. 519# errno_private.h is generated as part of ${SYSCALL_LIST_H_TARGET} target. 520add_dependencies(ot-config ${SYSCALL_LIST_H_TARGET}) 521 522# Make sure C library, in case of newlib, is linked after OpenThread libraries 523# (to prevent linker errors) 524if(CONFIG_NEWLIB_LIBC) 525 target_link_libraries(ot-config INTERFACE -lc) 526endif() 527 528# Include OpenThread headers 529zephyr_system_include_directories(${ZEPHYR_CURRENT_MODULE_DIR}/include) 530zephyr_system_include_directories(${ZEPHYR_CURRENT_MODULE_DIR}/examples/platforms) 531 532# Determine which libs should be linked in 533set(ot_libs "") 534 535if(CONFIG_OPENTHREAD_FTD) 536set(cli_lib openthread-cli-ftd) 537elseif(CONFIG_OPENTHREAD_MTD) 538set(cli_lib openthread-cli-mtd) 539endif() 540 541if(CONFIG_OPENTHREAD_SHELL) 542list(APPEND ot_libs ${cli_lib}) 543endif() 544 545if(CONFIG_OPENTHREAD_COPROCESSOR_RCP) 546list(APPEND ot_libs openthread-rcp) 547endif() 548 549if(CONFIG_OPENTHREAD_COPROCESSOR_NCP) 550if(CONFIG_OPENTHREAD_FTD) 551list(APPEND ot_libs openthread-ncp-ftd) 552elseif(CONFIG_OPENTHREAD_MTD) 553list(APPEND ot_libs openthread-ncp-mtd) 554endif() 555endif() 556 557if(NOT CONFIG_OPENTHREAD_COPROCESSOR_RCP) 558if(CONFIG_OPENTHREAD_FTD) 559list(APPEND ot_libs openthread-ftd) 560elseif(CONFIG_OPENTHREAD_MTD) 561list(APPEND ot_libs openthread-mtd) 562endif() 563endif() 564 565if(CONFIG_OPENTHREAD_SETTINGS_RAM) 566 target_compile_options(openthread-platform-utils PRIVATE 567 $<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS> -fno-builtin) 568 add_dependencies(openthread-platform-utils syscall_list_h_target) 569 570 list(APPEND ot_libs openthread-platform-utils-static) 571endif() 572 573zephyr_link_libraries(${ot_libs}) 574 575endif() 576 577add_subdirectory(platform) 578 579endif() 580