1if(CONFIG_OPENTHREAD_ENABLED) 2 if(CONFIG_OPENTHREAD_FTD) 3 include(ftd.cmake) 4 else() 5 include(radio.cmake) 6 endif() 7 8 if(CONFIG_OPENTHREAD_FTD) 9 set(device_type "OPENTHREAD_FTD=1") 10 elseif(CONFIG_OPENTHREAD_MTD) 11 set(device_type "OPENTHREAD_MTD=1") 12 elseif(CONFIG_OPENTHREAD_RADIO) 13 set(device_type "OPENTHREAD_RADIO=1") 14 endif() 15 16endif() 17 18execute_process( 19 COMMAND git rev-parse --short HEAD 20 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 21 OUTPUT_VARIABLE IDF_VERSION_FOR_OPENTHREAD_PACKAGE OUTPUT_STRIP_TRAILING_WHITESPACE 22) 23 24execute_process( 25 COMMAND git rev-parse --short HEAD 26 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/openthread 27 OUTPUT_VARIABLE OPENTHREAD_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE 28) 29 30idf_component_register(SRC_DIRS "${src_dirs}" 31 EXCLUDE_SRCS "${exclude_srcs}" 32 INCLUDE_DIRS "${public_include_dirs}" 33 PRIV_INCLUDE_DIRS "${private_include_dirs}" 34 REQUIRES mbedtls ieee802154 console) 35 36if(CONFIG_OPENTHREAD_ENABLED) 37 if(CONFIG_OPENTHREAD_RADIO) 38 set(CONFIG_FILE_TYPE "radio") 39 else() 40 set(CONFIG_FILE_TYPE "ftd") 41 endif() 42 43 target_compile_definitions( 44 ${COMPONENT_LIB} 45 PUBLIC 46 "OPENTHREAD_CONFIG_FILE=\"openthread-core-esp32x-${CONFIG_FILE_TYPE}-config.h\"" 47 "${device_type}" 48 PRIVATE 49 "PACKAGE_VERSION=\"${IDF_VERSION_FOR_OPENTHREAD_PACKAGE}-${OPENTHREAD_VERSION}\"") 50 51 if(CONFIG_OPENTHREAD_ESP_LIB_FROM_INTERNAL_SRC) 52 idf_component_get_property(openthread_port_lib openthread_port COMPONENT_LIB) 53 idf_component_get_property(esp_system_lib esp_system COMPONENT_LIB) 54 target_link_libraries(${COMPONENT_LIB} PUBLIC 55 $<TARGET_FILE:${openthread_port_lib}> 56 $<TARGET_FILE:${esp_system_lib}>) 57 58 if(CONFIG_OPENTHREAD_BORDER_ROUTER) 59 idf_component_get_property(openthread_br_lib openthread_br COMPONENT_LIB) 60 target_link_libraries(${COMPONENT_LIB} PUBLIC $<TARGET_FILE:${openthread_br_lib}>) 61 endif() 62 63 else() 64 add_prebuilt_library(openthread_port "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/libopenthread_port.a" 65 REQUIRES openthread) 66 add_prebuilt_library(openthread_br "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/libopenthread_br.a" 67 REQUIRES openthread) 68 69 target_link_libraries(${COMPONENT_LIB} INTERFACE openthread_port) 70 71 if(CONFIG_OPENTHREAD_BORDER_ROUTER) 72 target_link_libraries(${COMPONENT_LIB} INTERFACE openthread_br) 73 endif() 74 75 endif() 76 77endif() 78