Files
esp-idf/components/esp_partition/CMakeLists.txt
Frantisek Hrbata 36d3a180cf fix(esp_partition/cmake): remove unused PRIV_INCLUDE_DIRS
Currently, the bootloader version of the `esp_partition` component sets
`PRIV_INCLUDE_DIRS` using the `private_include_dirs` variable. However,
this variable is not properly initialized, which causes issues in
cmakev2. In cmakev2, components are evaluated recursively, and a
component may be evaluated in the context of another component, so
components must initialize all variables before using them.

Moreover, there are effectively no `PRIV_INCLUDE_DIRS` to set when the
component is evaluated for the bootloader. Therefore, remove
`PRIV_INCLUDE_DIRS` entirely for bootloader and test builds.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-04-27 22:07:10 +08:00

66 lines
2.0 KiB
CMake

idf_build_get_property(esp_tee_build ESP_TEE_BUILD)
set(reqs esp_blockdev)
# bootloader build simplified version
if(BOOTLOADER_BUILD)
set(srcs "partition_bootloader.c")
list(APPEND reqs spi_flash)
set(priv_reqs "bootloader_support" "efuse")
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include"
REQUIRES ${reqs}
PRIV_REQUIRES ${priv_reqs})
# esp-tee build simplified version
elseif(esp_tee_build)
set(srcs "partition_tee.c")
list(APPEND reqs spi_flash)
set(priv_reqs "tee_flash_mgr" "efuse")
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include"
REQUIRES ${reqs}
PRIV_REQUIRES ${priv_reqs})
# regular, OS build
else()
set(srcs "partition.c")
set(priv_reqs esp_system spi_flash partition_table efuse)
set(reqs esp_blockdev)
set(private_include_dirs)
idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
list(APPEND srcs "partition_linux.c")
# Steal some include directories from bootloader_support components:
idf_component_get_property(bootloader_support_dir bootloader_support COMPONENT_DIR)
set(private_include_dirs ${bootloader_support_dir}/include)
else()
list(APPEND priv_reqs bootloader_support app_update)
list(APPEND srcs "partition_target.c")
endif()
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS ${private_include_dirs}
REQUIRES ${reqs}
PRIV_REQUIRES ${priv_reqs})
if(${target} STREQUAL "linux")
# set BUILD_DIR because partition_linux.c uses a file created in the build directory
target_compile_definitions(${COMPONENT_LIB} PRIVATE "BUILD_DIR=\"${build_dir}\"")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
# These flags are GCC specific
set_property(SOURCE ${cache_srcs} APPEND_STRING PROPERTY COMPILE_FLAGS
" -fno-inline-small-functions -fno-inline-functions-called-once")
endif()
endif()