This commit is contained in:
kon72 2023-11-19 04:18:25 +09:00
Родитель e364b2dc93
Коммит efff003971
1 изменённых файлов: 17 добавлений и 20 удалений

Просмотреть файл

@ -3,39 +3,36 @@
function(bundle_static_library bundled_target_name)
function(recursively_collect_dependencies input_target)
set(input_link_libraries LINK_LIBRARIES)
get_target_property(alias ${input_target} ALIASED_TARGET)
if (TARGET ${alias})
set(input_target ${alias})
endif()
get_property(library_already_seen GLOBAL PROPERTY ${bundled_target_name}_static_bundle_${input_target})
if (library_already_seen)
return()
endif()
set_property(GLOBAL PROPERTY ${bundled_target_name}_static_bundle_${input_target} ON)
get_target_property(input_type ${input_target} TYPE)
if (${input_type} STREQUAL "STATIC_LIBRARY")
list(APPEND static_libs ${input_target})
endif()
set(input_link_libraries LINK_LIBRARIES)
if (${input_type} STREQUAL "INTERFACE_LIBRARY")
set(input_link_libraries INTERFACE_LINK_LIBRARIES)
endif()
get_target_property(public_dependencies ${input_target} ${input_link_libraries})
foreach(dependency IN LISTS public_dependencies)
if(TARGET ${dependency})
get_target_property(alias ${dependency} ALIASED_TARGET)
if (TARGET ${alias})
set(dependency ${alias})
endif()
get_target_property(type ${dependency} TYPE)
if (${type} STREQUAL "STATIC_LIBRARY")
list(APPEND static_libs ${dependency})
endif()
get_property(library_already_added GLOBAL PROPERTY ${target_name}_static_bundle_${dependency})
if (NOT library_already_added)
set_property(GLOBAL PROPERTY ${target_name}_static_bundle_${dependency} ON)
recursively_collect_dependencies(${dependency})
endif()
recursively_collect_dependencies(${dependency})
endif()
endforeach()
set(static_libs ${static_libs} PARENT_SCOPE)
endfunction()
foreach(target_name IN ITEMS ${ARGN})
get_target_property(alias ${target_name} ALIASED_TARGET)
if (TARGET ${alias})
set(target_name ${alias})
endif()
list(APPEND static_libs ${target_name})
recursively_collect_dependencies(${target_name})
endforeach()