Преглед изворни кода

Merge branch 'bugfix/do_not_require_new_target_link_library_signature' into 'master'

CMake: Do not force use of new target_link_libraries signature

See merge request espressif/esp-idf!5471
Angus Gratton пре 6 година
родитељ
комит
56afdedf7c
1 измењених фајлова са 10 додато и 7 уклоњено
  1. 10 7
      tools/cmake/component.cmake

+ 10 - 7
tools/cmake/component.cmake

@@ -295,7 +295,15 @@ macro(__component_set_dependencies reqs type)
     foreach(req ${reqs})
     foreach(req ${reqs})
         if(req IN_LIST build_component_targets)
         if(req IN_LIST build_component_targets)
             __component_get_property(req_lib ${req} COMPONENT_LIB)
             __component_get_property(req_lib ${req} COMPONENT_LIB)
-            target_link_libraries(${component_lib} ${type} ${req_lib})
+            if("${type}" STREQUAL "PRIVATE")
+                set_property(TARGET ${component_lib} APPEND PROPERTY LINK_LIBRARIES ${req_lib})
+                set_property(TARGET ${component_lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<LINK_ONLY:${req_lib}>)
+            elseif("${type}" STREQUAL "PUBLIC")
+                set_property(TARGET ${component_lib} APPEND PROPERTY LINK_LIBRARIES ${req_lib})
+                set_property(TARGET ${component_lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${req_lib})
+            else() # INTERFACE
+                set_property(TARGET ${component_lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${req_lib})
+            endif()
         endif()
         endif()
     endforeach()
     endforeach()
 endmacro()
 endmacro()
@@ -312,12 +320,7 @@ macro(__component_set_all_dependencies)
         __component_set_dependencies("${priv_reqs}" PRIVATE)
         __component_set_dependencies("${priv_reqs}" PRIVATE)
     else()
     else()
         __component_get_property(reqs ${component_target} __REQUIRES)
         __component_get_property(reqs ${component_target} __REQUIRES)
-        foreach(req ${reqs})
-            if(req IN_LIST build_component_targets)
-                __component_get_property(req_lib ${req} COMPONENT_LIB)
-                target_link_libraries(${component_lib} INTERFACE ${req_lib})
-            endif()
-        endforeach()
+        __component_set_dependencies("${reqs}" INTERFACE)
     endif()
     endif()
 endmacro()
 endmacro()