mirror of
https://github.com/espressif/esp-idf.git
synced 2026-07-23 03:13:01 +03:00
The __init_project_configuration() function in cmakev2's project.cmake unconditionally applied app-level compiler optimization flags based on CONFIG_COMPILER_OPTIMIZATION_* Kconfig options. When the bootloader subproject was built with cmakev2, these app-level flags leaked into the bootloader compile command alongside the correct bootloader-specific flags from CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_*. For example, with the default configuration (app: DEBUG, bootloader: SIZE), the bootloader received both "-Og -fno-shrink-wrap" (from app config) and "-Os -freorder-blocks" (from bootloader config). While GCC uses the last -O flag (-Os wins), the stray -fno-shrink-wrap persisted. Introduce a SET_COMPILER_OPTIMIZATION build property that defaults to YES when unset. Subprojects that manage their own optimization flags (like the bootloader) can set this to NO before calling idf_project_init() to prevent the default optimization flags from being applied. This keeps project.cmake generic without requiring it to know about specific subproject types. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>