# ESP-IDF component: copy this folder into your project's components/ directory.
# The static library for ${IDF_TARGET} comes from `tools/build_boards.sh mcu` (RISC-V chips) or
# the esp toolchain (Xtensa: esp32, esp32s2, esp32s3).
if(IDF_VERSION_MAJOR GREATER_EQUAL 5)
  set(AGRIQL_FLASH_COMPONENT esp_partition)
else()
  set(AGRIQL_FLASH_COMPONENT spi_flash)
endif()
idf_component_register(SRCS "agriql_esp_partition.c"
                       INCLUDE_DIRS "include"
                       REQUIRES ${AGRIQL_FLASH_COMPONENT})
set(AGRIQL_LIB "${CMAKE_CURRENT_LIST_DIR}/lib/${IDF_TARGET}/libagriql_edge.a")
if(NOT EXISTS "${AGRIQL_LIB}")
  message(FATAL_ERROR "agriql_edge: ${AGRIQL_LIB} missing; run tools/build_boards.sh mcu (and espup for Xtensa)")
endif()
add_prebuilt_library(agriql_edge_core "${AGRIQL_LIB}")
target_link_libraries(${COMPONENT_LIB} PUBLIC agriql_edge_core)
