diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index 36e4d1033e..1049e8de8f 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -624,12 +624,12 @@ 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 +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`). +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 is better to use the ``PRIV_REQUIRES`` feature in ``idf_component_register`` to create a dependency. However, in some cases, it's necessary to add 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:: diff --git a/docs/zh_CN/api-guides/build-system.rst b/docs/zh_CN/api-guides/build-system.rst index b093b9e25f..86b3a63f47 100644 --- a/docs/zh_CN/api-guides/build-system.rst +++ b/docs/zh_CN/api-guides/build-system.rst @@ -624,6 +624,23 @@ CMake 通常会在链接器命令行上重复两次组件库名称来自动处 - 项目导入 :ref:`project_include.cmake` 文件的顺序。 - 生成用于编译(通过 ``-I`` 参数)的头文件路径列表的顺序。请注意,对于给定组件的源文件,仅需将该组件的依赖组件的头文件路径告知编译器。 +添加链接时依赖项 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. highlight:: cmake + +ESP-IDF 的 CMake 辅助函数 ``idf_component_add_link_dependency`` 可以在组件之间添加仅作用于链接时的依赖关系。绝大多数情况下,我们都建议您使用 ``idf_component_register`` 中的 ``PRIV_REQUIRES`` 功能来构建依赖关系。然而在某些情况下,还是有必要添加另一个组件对当前组件的链接时依赖,即反转 ``PRIV_REQUIRES`` 中的依赖关系(参考示例::doc:`/api-reference/storage/spi_flash_override_driver`)。 + +要使另一个组件在链接时依赖于这个组件:: + + idf_component_add_link_dependency(FROM other_component) + +请将上述行置于 ``idf_component_register`` 行之后。 + +也可以通过名称指定两个组件:: + + idf_component_add_link_dependency(FROM other_component TO that_component) + .. _override_project_config: 覆盖项目的部分设置