mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
cmake: use new signature form of target_link_library to link components
!4452 used setting LINK_LIBRARIES and INTERFACE_LINK_LIBRARIES to link components built under ESP-IDF build system. However, LINK_LIBRARIES does not produce behavior same as linking PRIVATE. This MR uses the new signature for target_link_libraries directly instead. This also moves setting dependencies during component registration rather than after all components have been processed. The consequence is that internally, components have to use the new signature form as well. This does not affect linking the components to external targets, such as with idf_as_lib example. This only affects linking additional libraries to ESP-IDF libraries outside component processing (after idf_build_process), which is not even possible for CMake<v3.13 as target_link_libraries is not valid for targets not created in current directory. See https://cmake.org/cmake/help/v3.13/policy/CMP0079.html#policy:CMP0079
This commit is contained in:
+1
-27
@@ -79,30 +79,4 @@ foreach(component_target ${build_component_targets})
|
||||
add_subdirectory(${dir} ${_name})
|
||||
endif()
|
||||
set(__idf_component_context 0)
|
||||
endforeach()
|
||||
|
||||
# Establish dependencies between components
|
||||
idf_build_get_property(build_components BUILD_COMPONENTS)
|
||||
foreach(build_component ${build_components})
|
||||
__component_get_target(component_target ${build_component})
|
||||
__component_get_property(component_lib ${component_target} COMPONENT_LIB)
|
||||
__component_get_property(reqs ${component_target} __REQUIRES)
|
||||
foreach(req ${reqs})
|
||||
__component_get_property(req_lib ${req} COMPONENT_LIB)
|
||||
if(TARGET ${req_lib})
|
||||
set_property(TARGET ${component_lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${req_lib})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
get_property(type TARGET ${component_lib} PROPERTY TYPE)
|
||||
if(type STREQUAL STATIC_LIBRARY)
|
||||
__component_get_property(reqs ${component_target} __REQUIRES)
|
||||
__component_get_property(priv_reqs ${component_target} __PRIV_REQUIRES)
|
||||
foreach(req ${reqs} ${priv_reqs})
|
||||
__component_get_property(req_lib ${req} COMPONENT_LIB)
|
||||
if(TARGET ${req_lib})
|
||||
set_property(TARGET ${component_lib} APPEND PROPERTY LINK_LIBRARIES ${req_lib})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
Reference in New Issue
Block a user