fix(cmakev2/component): use component interface in dependency chain

The dependency chain currently tracks component names that are included
recursively with `idf_component_include`. However, these component names
can be ambiguous because a component may be referenced by different
names, such as with a namespace. Additionally, `idf_component_include`
can accept anything that `__get_component_interface` accepts, meaning
even the component interface target can be used to include the component
in the build. To uniquely identify each component, use component
interface targets instead of names in the dependency chain.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2026-03-20 08:13:26 +01:00
parent cdcb4cbce8
commit 50876225a3
+3 -3
View File
@@ -885,12 +885,12 @@ function(idf_component_include name)
# helps in detecting and reporting circular dependencies, such as # helps in detecting and reporting circular dependencies, such as
# C1->C2->C1. In this scenario, C2 can still use the C1 interface target, # C1->C2->C1. In this scenario, C2 can still use the C1 interface target,
# but C1 will only be fully evaluated after C2 has been evaluated. # but C1 will only be fully evaluated after C2 has been evaluated.
if("${component_name}" IN_LIST __DEPENDENCY_CHAIN) if("${component_interface}" IN_LIST __DEPENDENCY_CHAIN)
idf_dbg("Component '${name}' in circular dependency chain '${__DEPENDENCY_CHAIN}'") idf_dbg("Component '${component_interface}' in circular dependency chain '${__DEPENDENCY_CHAIN}'")
return() return()
endif() endif()
list(APPEND __DEPENDENCY_CHAIN "${name}") list(APPEND __DEPENDENCY_CHAIN "${component_interface}")
# Evaluate the CMakeLists.txt file of the component. # Evaluate the CMakeLists.txt file of the component.
idf_component_get_property(component_build_dir "${component_name}" COMPONENT_BUILD_DIR) idf_component_get_property(component_build_dir "${component_name}" COMPONENT_BUILD_DIR)
add_subdirectory("${component_directory}" "${component_build_dir}") add_subdirectory("${component_directory}" "${component_build_dir}")