1if( NOT CONFIG_ESP_WIFI_ENABLED
2    AND NOT CMAKE_BUILD_EARLY_EXPANSION )
3    # No local wifi: provide only netif bindings
4    set(srcs
5            "src/wifi_default.c"
6            "src/wifi_netif.c"
7            "src/wifi_default_ap.c")
8
9    # This component provides "esp_wifi" "wifi_apps" headers if WiFi not enabled
10    # (implementation supported optionally in a managed component esp_wifi_remote)
11    idf_component_register(SRCS "${srcs}"
12                    INCLUDE_DIRS "include" "wifi_apps/include")
13    return()
14endif()
15
16if(CONFIG_ESP_WIFI_ENABLED)
17    idf_build_get_property(idf_target IDF_TARGET)
18
19    if(CONFIG_APP_NO_BLOBS)
20        set(link_binary_libs 0)
21        set(ldfragments)
22    else()
23        set(link_binary_libs 1)
24        set(ldfragments "linker.lf")
25    endif()
26
27    if(IDF_TARGET_ESP32)
28        # dport workaround headers are in esp32 component
29        set(extra_priv_requires esp32)
30    else()
31        set(extra_priv_requires)
32    endif()
33
34    set(srcs
35        "src/mesh_event.c"
36        "src/smartconfig.c"
37        "src/wifi_init.c"
38        "src/wifi_default.c"
39        "src/wifi_netif.c"
40        "src/wifi_default_ap.c"
41        "${idf_target}/esp_adapter.c")
42
43    if(CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API AND CONFIG_LWIP_IPV4)
44        list(APPEND srcs
45            "src/smartconfig_ack.c")
46    endif()
47
48    if(CONFIG_ESP_WIFI_NAN_ENABLE)
49        list(APPEND srcs "wifi_apps/src/nan_app.c")
50    endif()
51
52endif()
53
54idf_component_register(SRCS "${srcs}"
55                    INCLUDE_DIRS "include" "wifi_apps/include"
56                    REQUIRES esp_event esp_phy esp_netif
57                    PRIV_REQUIRES driver esptool_py esp_pm esp_timer nvs_flash
58                                  wpa_supplicant hal lwip esp_coex ${extra_priv_requires}
59                    LDFRAGMENTS "${ldfragments}")
60
61if(CONFIG_ESP_WIFI_ENABLED)
62    idf_build_get_property(build_dir BUILD_DIR)
63
64    set(target_name "${idf_target}")
65    target_link_directories(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}")
66
67    if(link_binary_libs)
68        if(CONFIG_IDF_TARGET_ESP32C2)
69            set(blobs core espnow net80211 pp smartconfig)
70        else()
71            set(blobs core espnow mesh net80211 pp smartconfig wapi)
72        endif()
73
74        foreach(blob ${blobs})
75            add_prebuilt_library(${blob} "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}/lib${blob}.a"
76                                REQUIRES ${COMPONENT_NAME})
77            set(blob_reqs ${blobs})
78            list(REMOVE_ITEM blob_reqs ${blob}) # remove itself from requirements
79            set_property(TARGET ${blob} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${blob_reqs})
80            target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob})
81        endforeach()
82    endif()
83
84    if(CONFIG_SPIRAM)
85        idf_component_optional_requires(PRIVATE esp_psram)
86    endif()
87
88endif()
89