diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index f5d7a6f8b..3fdc0284e 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -308,6 +308,8 @@ The list of directories in ``COMPONENT_DIRS`` is searched for the project's comp When CMake runs to configure the project, it logs the components included in the build. This list can be useful for debugging the inclusion/exclusion of certain components. +.. _cmake-components-same-name: + Multiple components with the same name -------------------------------------- @@ -1313,6 +1315,7 @@ For example, to get the directory of the ``freertos`` component: - COMPONENT_ALIAS - alias for COMPONENT_LIB used for linking the component to external targets; set by ``idf_build_component`` and alias library itself is created by ``idf_component_register`` - COMPONENT_DIR - component directory; set by ``idf_build_component`` +- COMPONENT_OVERRIDEN_DIR - contains the directory of the original component if ref:`this component overrides another component` - COMPONENT_LIB - name for created component static/interface library; set by ``idf_build_component`` and library itself is created by ``idf_component_register`` - COMPONENT_NAME - name of the component; set by ``idf_build_component`` based on the component directory name diff --git a/tools/cmake/component.cmake b/tools/cmake/component.cmake index b9b035bc5..b5b7e3ae9 100644 --- a/tools/cmake/component.cmake +++ b/tools/cmake/component.cmake @@ -171,6 +171,9 @@ function(__component_add component_dir prefix) add_library(${component_target} STATIC IMPORTED) endif() idf_build_set_property(__COMPONENT_TARGETS ${component_target} APPEND) + else() + __component_get_property(dir ${component_target} COMPONENT_DIR) + __component_set_property(${component_target} COMPONENT_OVERRIDEN_DIR ${dir}) endif() set(component_lib __${prefix}_${component_name})