feat(cmakev2/idf): initialize SDKCONFIG and SDKCONFIG_DEFAULTS build properties

Based on the environmental variables, CMake cache variables, or default
values, set the DKCONFIG and SDKCONFIG_DEFAULTS build properties.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2025-07-11 13:40:58 +02:00
parent 7efff764cb
commit 71d21b45e1
+38
View File
@@ -92,6 +92,41 @@ function(__init_python)
endif()
endfunction()
#[[
__init_sdkconfig_files()
Set the SDKCONFIG and SDKCONFIG_DEFAULTS build properties using environment
variables, CMake cache variables, or default values.
#]]
function(__init_sdkconfig_files)
if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
set(sdkconfig_defaults "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
else()
set(sdkconfig_defaults "")
endif()
__get_default_value(VARIABLE SDKCONFIG
DEFAULT "${CMAKE_SOURCE_DIR}/sdkconfig"
OUTPUT sdkconfig)
__get_default_value(VARIABLE SDKCONFIG_DEFAULTS
DEFAULT "${sdkconfig_defaults}"
OUTPUT sdkconfig_defaults)
__get_absolute_paths(PATHS "${sdkconfig}" OUTPUT sdkconfig)
__get_absolute_paths(PATHS "${sdkconfig_defaults}" OUTPUT sdkconfig_defaults)
set(sdkconfig_defaults_checked "")
foreach(sdkconfig_default ${sdkconfig_defaults})
if(NOT EXISTS "${sdkconfig_default}")
idf_die("SDKCONFIG_DEFAULTS '${sdkconfig_default}' does not exist.")
endif()
list(APPEND sdkconfig_defaults_checked ${sdkconfig_default})
endforeach()
idf_build_set_property(SDKCONFIG "${sdkconfig}")
idf_build_set_property(SDKCONFIG_DEFAULTS "${sdkconfig_defaults_checked}")
endfunction()
#[[
__init_components()
@@ -196,6 +231,9 @@ __init_idf_path()
# Determine the Python interpreter and check package dependencies if necessary.
__init_python()
# Set SDKCONFIG and SDKCONFIG_DEFAULTS build properties.
__init_sdkconfig_files()
# Discover and initialize components.
__init_components()