Merge branch 'fix/cmakev2_idf_component_optional_requires' into 'master'

fix(cmakev2/compat): change idf_component_optional_requires behavior

Closes IDFGH-17112

See merge request espressif/esp-idf!45588
This commit is contained in:
Frantisek Hrbata
2026-02-12 08:50:24 +01:00
2 changed files with 38 additions and 8 deletions
+7
View File
@@ -432,6 +432,13 @@ Strict Component Precedence
The v2 strictly adheres to the component precedence for components with the same name, as described in :ref:`cmake-components-same-name`. While v1 allows components discovered in directories specified with the ``EXTRA_COMPONENT_DIRS`` variable to be overridden by `Local Directory Dependencies`_ specified in the ``idf_component.yml`` manifest file, this is no longer possible in v2.
The Behavior of ``idf_component_optional_requires`` has Changed
---------------------------------------------------------------
In v1, the ``idf_component_optional_requires`` function adds a dependency on a specified component only if that component is already included in the build (for instance, if it is already required by another component). To achieve this, v1 examines the ``BUILD_COMPONENTS`` build property, which is generated during the early evaluation phase and lists all components involved in the build.
In v2, the ``BUILD_COMPONENTS`` build property is no longer available because the early evaluation phase has been removed. Consequently, the function now adds the dependency if the component is recognized by the build system. This behavior may pull unnecessary components into the build, leading to longer build times. Using ``idf_component_optional_requires`` in v2 should be avoided, instead, optional dependencies should be added using conditional logic based on the project configuration.
API Reference
=============