diff --git a/cmake/Modules/CocosBuildHelpers.cmake b/cmake/Modules/CocosBuildHelpers.cmake index 2eb6b149cf..38ece29037 100644 --- a/cmake/Modules/CocosBuildHelpers.cmake +++ b/cmake/Modules/CocosBuildHelpers.cmake @@ -62,17 +62,22 @@ function(search_depend_libs_recursive cocos_target all_depends_out) set(targets_prepare_search ${cocos_target}) while(true) foreach(tmp_target ${targets_prepare_search}) - get_target_property(tmp_depend_libs ${tmp_target} LINK_LIBRARIES) - list(REMOVE_ITEM targets_prepare_search ${tmp_target}) - list(APPEND tmp_depend_libs ${tmp_target}) - foreach(depend_lib ${tmp_depend_libs}) - if(TARGET ${depend_lib}) - list(APPEND all_depends_inner ${depend_lib}) - if(NOT (depend_lib STREQUAL tmp_target)) - list(APPEND targets_prepare_search ${depend_lib}) + get_target_property(target_type ${tmp_target} TYPE) + if(${target_type} STREQUAL "SHARED_LIBRARY" OR ${target_type} STREQUAL "STATIC_LIBRARY" OR ${target_type} STREQUAL "MODULE_LIBRARY" OR ${target_type} STREQUAL "EXECUTABLE") + get_target_property(tmp_depend_libs ${tmp_target} LINK_LIBRARIES) + list(REMOVE_ITEM targets_prepare_search ${tmp_target}) + list(APPEND tmp_depend_libs ${tmp_target}) + foreach(depend_lib ${tmp_depend_libs}) + if(TARGET ${depend_lib}) + list(APPEND all_depends_inner ${depend_lib}) + if(NOT (depend_lib STREQUAL tmp_target)) + list(APPEND targets_prepare_search ${depend_lib}) + endif() endif() - endif() - endforeach() + endforeach() + else() + list(REMOVE_ITEM targets_prepare_search ${tmp_target}) + endif() endforeach() list(LENGTH targets_prepare_search targets_prepare_search_size) if(targets_prepare_search_size LESS 1) @@ -90,10 +95,13 @@ function(get_target_depends_ext_dlls cocos_target all_depend_dlls_out) search_depend_libs_recursive(${cocos_target} depend_libs) foreach(depend_lib ${depend_libs}) if(TARGET ${depend_lib}) - get_target_property(found_shared_lib ${depend_lib} IMPORTED_IMPLIB) - if(found_shared_lib) - get_target_property(tmp_dlls ${depend_lib} IMPORTED_LOCATION) - list(APPEND all_depend_ext_dlls ${tmp_dlls}) + get_target_property(target_type ${depend_lib} TYPE) + if(${target_type} STREQUAL "SHARED_LIBRARY" OR ${target_type} STREQUAL "STATIC_LIBRARY" OR ${target_type} STREQUAL "MODULE_LIBRARY" OR ${target_type} STREQUAL "EXECUTABLE") + get_target_property(found_shared_lib ${depend_lib} IMPORTED_IMPLIB) + if(found_shared_lib) + get_target_property(tmp_dlls ${depend_lib} IMPORTED_LOCATION) + list(APPEND all_depend_ext_dlls ${tmp_dlls}) + endif() endif() endif() endforeach()