mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
feat(build): propagate compiler flags from files to toolchain.cmake
This change improves build consistency across external projects integrated through CMake by ensuring that compiler flags defined in configuration files are passed correctly to the toolchain. It covers the majority of use cases, as external projects are typically also CMake-based. For projects that use a custom build system, users will still need to specify the required flags manually.
This commit is contained in:
@@ -1,17 +1,34 @@
|
||||
if(CONFIG_IDF_TARGET_ESP32 AND CONFIG_SPIRAM_CACHE_WORKAROUND AND NOT BOOTLOADER_BUILD)
|
||||
# We do this here as well as in CMakeLists.txt, because targets that
|
||||
# are not part of the ESP-IDF build system (for cases where a generic
|
||||
# non-IDF CMakeLists.txt file is imported into a component) don't depend
|
||||
# on the esp32 component so don't get the extra flag. This handles that case.
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-issue" APPEND)
|
||||
# note that we don't need to set link options as the library linked is independent of this
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=dupldst" APPEND)
|
||||
if(CONFIG_IDF_TOOLCHAIN_GCC)
|
||||
# Remove all "-mfix-esp32-psram-cache*" from toolchain flags
|
||||
# that may have appeared during configuration changes.
|
||||
idf_toolchain_remove_flags(COMPILE_OPTIONS "-mfix-esp32-psram-cache")
|
||||
if(CONFIG_IDF_TARGET_ESP32 AND CONFIG_SPIRAM_CACHE_WORKAROUND AND NOT BOOTLOADER_BUILD)
|
||||
idf_toolchain_add_flags(COMPILE_OPTIONS "-mfix-esp32-psram-cache-issue")
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST)
|
||||
idf_toolchain_add_flags(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=dupldst")
|
||||
endif()
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW)
|
||||
idf_toolchain_add_flags(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=memw")
|
||||
endif()
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS)
|
||||
idf_toolchain_add_flags(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=nops")
|
||||
endif()
|
||||
endif()
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=memw" APPEND)
|
||||
endif()
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=nops" APPEND)
|
||||
else()
|
||||
if(CONFIG_IDF_TARGET_ESP32 AND CONFIG_SPIRAM_CACHE_WORKAROUND AND NOT BOOTLOADER_BUILD)
|
||||
# We do this here as well as in CMakeLists.txt, because targets that
|
||||
# are not part of the ESP-IDF build system (for cases where a generic
|
||||
# non-IDF CMakeLists.txt file is imported into a component) don't depend
|
||||
# on the esp32 component so don't get the extra flag. This handles that case.
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-issue" APPEND)
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=dupldst" APPEND)
|
||||
endif()
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=memw" APPEND)
|
||||
endif()
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=nops" APPEND)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user