build system: Add idf_component_add_link_dependency function, use for spi_flash overriding

This commit is contained in:
Angus Gratton
2021-06-29 18:19:12 +10:00
committed by Ivan Grokhotkov
parent a3dd334081
commit d89652b382
4 changed files with 61 additions and 6 deletions

View File

@@ -605,6 +605,23 @@ The order of components in the ``BUILD_COMPONENTS`` variable determines other or
- Order that :ref:`project_include.cmake` files are included into the project.
- Order that the list of header paths is generated for compilation (via ``-I`` argument). (Note that for a given component's source files, only that component's dependency's header paths are passed to the compiler.)
Adding link-time dependencies
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. highlight:: cmake
The ESP-IDF CMake helper function ``idf_component_add_link_dependency`` adds a link-only dependency between one component and another. In almost all cases, it's better to use the ``PRIV_REQUIRES`` feature in ``idf_component_register`` to create a dependency. However in some cases it's necessary the link-time dependency of another component to this component, i.e. the reverse order to ``PRIV_REQUIRES`` (for example: :doc:`/api-reference/storage/spi_flash_override_driver`).
To make another component depend on this component at link time::
idf_component_add_link_dependency(FROM other_component)
Place this line after the line with ``idf_component_register``.
It's also possible to specify both components by name::
idf_component_add_link_dependency(FROM other_component TO that_component)
.. _override_project_config:
Overriding Parts of the Project