fix(cmakev2): propagate IDF_TOOLCHAIN selection to sdkconfig generation

In the cmakev2 build framework, the selected toolchain was not
consistently propagated to sdkconfig generation. For clang builds,
this produced a configuration that was incompatible with the clang
toolchain and broke compilation.

Ensure the toolchain selection is observed consistently so sdkconfig
and component configuration reflect the intended toolchain for both
GCC and clang builds.

Made-with: Cursor
This commit is contained in:
Sudeep Mohanty
2026-04-16 16:19:28 +02:00
parent 7a778c02e4
commit 054c15eab3
+7
View File
@@ -317,6 +317,13 @@ function(__init_toolchain)
idf_die("Toolchain file ${toolchain_file} not found")
endif()
# IDF_TOOLCHAIN applies to Espressif targets only; on linux (host build)
# it must stay empty so Kconfig leaves both CONFIG_IDF_TOOLCHAIN_GCC and
# CONFIG_IDF_TOOLCHAIN_CLANG unset.
if(NOT "${idf_target}" STREQUAL "linux")
set(IDF_TOOLCHAIN "${toolchain}" CACHE STRING "IDF Build Toolchain Type" FORCE)
endif()
set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}" PARENT_SCOPE)
idf_build_set_property(IDF_TOOLCHAIN_FILE "${toolchain_file}")
endfunction()