fix(cmakev2): mirror sdkconfig CONFIG_* onto build properties

Read sdkconfig.cmake's CONFIG_* values and re-publish them on the
build-properties target so component CMakeLists.txt code that queries
Kconfig via idf_build_get_property(var CONFIG_FOO) returns the expected
value.
This commit is contained in:
Sudeep Mohanty
2026-05-18 13:38:26 +02:00
parent 61ac863963
commit 0424ef01c5
2 changed files with 28 additions and 0 deletions

View File

@@ -922,3 +922,27 @@ function(idf_build_component component_dir)
PREFIX "${component_prefix}"
SOURCE "${component_source}")
endfunction()
#[[
__import_sdkconfig_as_build_properties()
Mirror every CONFIG_* symbol from the generated sdkconfig.cmake onto the
build-properties target so that the
`idf_build_get_property(var CONFIG_FOO)` idiom keeps working under the
compatibility shim. Called from kconfig.cmake::__generate_sdkconfig after
each kconfgen run.
#]]
function(__import_sdkconfig_as_build_properties)
idf_build_get_property(sdkconfig_cmake __SDKCONFIG_CMAKE)
if(NOT sdkconfig_cmake OR NOT EXISTS "${sdkconfig_cmake}")
return()
endif()
include("${sdkconfig_cmake}")
if(NOT DEFINED CONFIGS_LIST)
return()
endif()
idf_build_set_property(__CONFIG_VARIABLES "${CONFIGS_LIST}")
foreach(config IN LISTS CONFIGS_LIST)
idf_build_set_property("${config}" "${${config}}")
endforeach()
endfunction()

View File

@@ -208,6 +208,10 @@ function(__generate_sdkconfig)
# Generate Kconfig outputs
__generate_kconfig_outputs()
# Mirror CONFIG_* values onto build properties so
# `idf_build_get_property(var CONFIG_FOO)` keeps working.
__import_sdkconfig_as_build_properties()
idf_msg("Generated sdkconfig configuration")
endfunction()