fix(cmakev2/component): remove EXCLUDE_FROM_ALL when calling add_subdirectory

Currently, cmakev2 evaluates each component using add_subdirectory with
the EXCLUDE_FROM_ALL option. The intention was to exclude all components
from being built by default unless they are explicitly linked to an
executable based on dependencies. This approach aims to avoid building
components that are included but not actually linked to the executable.
However, this has the side effect of preventing components from adding
their custom targets to the "all" target, which is used, for example, by
esp_phy. Generally, we should not restrict components from adding
targets to "all". Since components are only included if explicitly
requested by default, removing the EXCLUDE_FROM_ALL option should be
acceptable.

The downside is that if IDF_INCLUDE_ALL_COMPONENTS is set and the user
runs `idf.py build`, all components will be built, even if they are not
linked to the executable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2025-11-04 07:48:14 +01:00
parent de26190732
commit b663ebd1da
+1 -1
View File
@@ -858,7 +858,7 @@ function(idf_component_include name)
list(APPEND __DEPENDENCY_CHAIN "${name}")
# Evaluate the CMakeLists.txt file of the component.
idf_build_get_property(build_dir BUILD_DIR build_dir)
add_subdirectory("${component_directory}" "${build_dir}/esp-idf/${component_name}" EXCLUDE_FROM_ALL)
add_subdirectory("${component_directory}" "${build_dir}/esp-idf/${component_name}")
# The component has been evaluated; remove it from the dependency chain.
list(POP_BACK __DEPENDENCY_CHAIN)