# SquareLine Studio export plus the hand-written bridge that connects it to the
# rest of the firmware.
#
# Only src/ui_app.c is maintained by hand. Everything under generated/ comes
# out of SquareLine Studio via tools/squareline_sync.ps1 — edit it there, or
# your changes will be overwritten on the next export.

# This glob deliberately does NOT use CONFIGURE_DEPENDS.
#
# ESP-IDF reads component CMakeLists.txt in CMake *script mode* during its
# requirements pass, and CMake rejects that keyword outright there:
#
#   CMake Error at components/ui/CMakeLists.txt:12 (file):
#     CONFIGURE_DEPENDS is invalid for script and find package modes.
#
# The cost is that a newly exported screen would not be picked up by an
# incremental build. tools/squareline_sync.ps1/.sh therefore touches this file
# after every export, which makes CMake re-run the glob on the next build. If
# you add sources by hand instead, run `idf.py reconfigure`.
file(GLOB_RECURSE UI_GENERATED_SOURCES
     "${CMAKE_CURRENT_LIST_DIR}/generated/*.c")

if(NOT UI_GENERATED_SOURCES)
    message(WARNING
        "components/ui/generated contains no .c files. "
        "Restore the placeholder ui.c or run tools/squareline_sync.ps1 — "
        "otherwise ui_init() will be undefined and the link will fail.")
endif()

idf_component_register(
    SRCS
        "src/ui_app.c"
        ${UI_GENERATED_SOURCES}
    INCLUDE_DIRS
        "include"
        # SquareLine's own files do #include "ui.h", so the export folder has
        # to be on the include path as-is.
        "generated"
    REQUIRES
        lvgl
        bsp_jc3636k718c
)
