diff --git a/tools/cmakev2/idf.cmake b/tools/cmakev2/idf.cmake index 42574f8c4f..1e1f954992 100644 --- a/tools/cmakev2/idf.cmake +++ b/tools/cmakev2/idf.cmake @@ -458,6 +458,24 @@ function(__init_submodules) endforeach() endfunction() +#[[ + __init_idf_target_arch() + + Set the IDF_TARGET_ARCH value based on the sdkconfig. This means it must be + initialized after the sdkconfig is generated and its CMake version is + included. +#]] +function(__init_idf_target_arch) + if(CONFIG_IDF_TARGET_ARCH_XTENSA) + idf_build_set_property(IDF_TARGET_ARCH "xtensa") + elseif(CONFIG_IDF_TARGET_ARCH_RISCV) + idf_build_set_property(IDF_TARGET_ARCH "riscv") + else() + # Currently, no architecture is specified for Linux host builds. + idf_build_set_property(IDF_TARGET_ARCH "") + endif() +endfunction() + #[[ The idf_build_properties interface target is exclusively used to store information about global build properties and is not linked or used in any @@ -556,6 +574,10 @@ if(NOT EXISTS "${sdkconfig_cmake}") endif() include("${sdkconfig_cmake}") +# Initialize the target architecture based on the configuration. Ensure this is +# done after including the sdkconfig. +__init_idf_target_arch() + #[[ TODO Many of the following things are already implemented in PoC !38337, but they