idf_build_get_property(target IDF_TARGET)

if(${target} STREQUAL "linux")
    return() # This component is not supported by the POSIX/Linux simulator
endif()

set(srcs "src/network_config.c"
        "src/network_scan.c"
        "src/network_ctrl.c"
        "src/manager.c"
        "src/handlers.c"
        "src/scheme_console.c"
        "proto-c/network_config.pb-c.c"
        "proto-c/network_scan.pb-c.c"
        "proto-c/network_ctrl.pb-c.c"
        "proto-c/network_constants.pb-c.c")

if((CONFIG_ESP_WIFI_ENABLED OR CONFIG_ESP_WIFI_REMOTE_ENABLED) AND CONFIG_ESP_WIFI_SOFTAP_SUPPORT)
    list(APPEND srcs "src/scheme_softap.c")
endif()

if(CONFIG_BT_ENABLED)
    if(CONFIG_BT_BLUEDROID_ENABLED OR CONFIG_BT_NIMBLE_ENABLED)
        list(APPEND srcs
            "src/scheme_ble.c")
    endif()
endif()

set(priv_requires protobuf-c bt esp_timer esp_wifi openthread)

# For IDF < 6.0, use IDF's built-in json component; for IDF >= 6.0 use managed cJSON component
if("${IDF_VERSION_MAJOR}" VERSION_LESS "6")
    list(APPEND priv_requires json)
endif()

idf_component_register(SRCS "${srcs}"
                    INCLUDE_DIRS include
                    PRIV_INCLUDE_DIRS src proto-c
                    REQUIRES lwip protocomm
                    PRIV_REQUIRES ${priv_requires})
