cmake_minimum_required(VERSION 3.16)

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

set(EXTRA_COMPONENT_DIRS "lib")
list(APPEND EXTRA_COMPONENT_DIRS "src")

project(p4-bridge)

# ESP32-P4 specific configurations
idf_build_set_property(COMPILE_OPTIONS "-Wno-error=format" APPEND)
idf_build_set_property(COMPILE_OPTIONS "-Wno-format" APPEND)

# Disable the problematic --enable-non-contiguous-regions flag for ESP32-P4
idf_build_set_property(LINK_OPTIONS "--disable-non-contiguous-regions" APPEND)

# ESP32-P4 specific configurations based on research
# ESP32-P4 doesn't have built-in WiFi - requires external ESP32-C6 module
# Using ESP-Hosted-FG for wireless connectivity
idf_build_set_property(COMPILE_DEFINITIONS "ESP32_P4_NO_BUILTIN_WIFI" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "USE_ESP_HOSTED_FG" APPEND)

# Add ESP-Hosted-FG component when available
# TODO: Add ESP-Hosted-FG component for proper WiFi support
set(EXTRA_COMPONENT_DIRS ${EXTRA_COMPONENT_DIRS} "lib/esp-hosted-fg")
