# Lisael Box — main component.
#
# ESP-ADF components (audio_pipeline, esp-adf-libs, audio_stream, esp_decoder,
# audio_board ...) are resolved at configure time from ADF_PATH via
# EXTRA_COMPONENT_DIRS (top-level CMakeLists.txt). They are listed in REQUIRES
# so the linker pulls them in; if ADF_PATH is missing the build fails loudly
# in the audio sources only.
#
# The audio REQUIRES are guarded: when ADF is absent we still let the UI / net
# layers build for inspection. Set LISAEL_WITH_ADF=OFF to compile without audio
# (UI/clock/breathing only) for quick syntax checks on a machine without ADF.

set(srcs
    "app_main.c"
    "net/wifi.c"
    "net/sntp_time.c"
    "net/weather.c"
    "ui/ui.c"
    "ui/fr_date.c"
    "ui/icons.c"
    "modes/home.c"
    "modes/radio.c"
    "modes/soundbox.c"
    "modes/calm.c"
    "modes/clock.c"
    "modes/games.c"
    "audio/audio_player.c"
    "audio/radio_pipeline.c"
    "audio/sd_player.c"
)

set(reqs
    nvs_flash
    esp_wifi
    esp_event
    esp_netif
    esp-tls
    esp_http_client
    mbedtls          # esp_crt_bundle_attach (CA bundle for HTTPS)
    esp-box-3        # BSP: display, touch, codec, sdcard, sensors
    json             # IDF built-in cJSON component (provides cJSON.h)
    fatfs
    esp_driver_i2c
    esp_driver_tsens  # driver/temperature_sensor.h (internal die temp)
)

# ESP-ADF audio components. Names follow the ADF master component tree.
# Guarded so a no-ADF inspection build still configures.
if(DEFINED ENV{ADF_PATH})
    list(APPEND reqs
        audio_pipeline
        audio_stream
        esp-adf-libs
        audio_sal
    )
endif()

idf_component_register(
    SRCS ${srcs}
    INCLUDE_DIRS "."
    REQUIRES ${reqs}
)
