# Lisael Box — top-level project CMake for ESP-IDF 5.4/5.5
# Target: ESP32-S3-BOX-3
cmake_minimum_required(VERSION 3.16)

# --- ESP-ADF integration -----------------------------------------------------
# ESP-ADF is NOT a managed component: it is installed separately and exposed via
# the ADF_PATH environment variable (see README "Installer ESP-ADF").
# We add its component tree to EXTRA_COMPONENT_DIRS so that audio_pipeline,
# http_stream, esp_decoder, fatfs_stream, i2s_stream etc. become available.
#
# If ADF_PATH is unset the project still configures, but the audio modules that
# need ADF will fail to link. We surface a clear message instead of a cryptic
# "component not found" error.
if(DEFINED ENV{ADF_PATH})
    set(ADF_COMPONENTS "$ENV{ADF_PATH}/components")
    if(EXISTS "${ADF_COMPONENTS}")
        list(APPEND EXTRA_COMPONENT_DIRS "${ADF_COMPONENTS}")
        message(STATUS "Lisael Box: ESP-ADF components from ${ADF_COMPONENTS}")
    else()
        message(WARNING "Lisael Box: ADF_PATH set but ${ADF_COMPONENTS} not found")
    endif()
else()
    message(WARNING
        "Lisael Box: ADF_PATH not set. Audio streaming (webradio / SD playback) "
        "will not link. Run '. $ADF_PATH/export.sh' or export ADF_PATH. "
        "See README.")
endif()

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(lisael_box)
