forked from blitz-research/dawn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
function(create_bundled_lib output_lib output_libname input_lib) | ||
|
||
function(collect_dependencies target) | ||
|
||
if (NOT TARGET ${target}) | ||
return() | ||
endif () | ||
|
||
get_target_property(alias ${target} ALIASED_TARGET) | ||
if (TARGET ${alias}) | ||
set(target ${alias}) | ||
endif () | ||
|
||
set(done_prop bundled_lib_${output_lib}_${target}_done) | ||
get_property(done GLOBAL PROPERTY ${done_prop}) | ||
if (done) | ||
return() | ||
endif () | ||
set_property(GLOBAL PROPERTY ${done_prop} ON) | ||
|
||
get_target_property(_type ${target} TYPE) | ||
if (${_type} STREQUAL "STATIC_LIBRARY") | ||
list(APPEND static_libs ${target}) | ||
endif () | ||
|
||
set(_link_libs_type LINK_LIBRARIES) | ||
if (${_type} STREQUAL "INTERFACE_LIBRARY") | ||
set(_link_libs_type INTERFACE_LINK_LIBRARIES) | ||
endif () | ||
get_target_property(target_dependencies ${target} ${_link_libs_type}) | ||
|
||
foreach (dependency IN LISTS target_dependencies) | ||
collect_dependencies(${dependency}) | ||
endforeach () | ||
|
||
set(static_libs ${static_libs} PARENT_SCOPE) | ||
|
||
endfunction() | ||
|
||
collect_dependencies(${input_lib}) | ||
|
||
list(REMOVE_DUPLICATES static_libs) | ||
|
||
# message("### Static lib dependencies: ${static_libs}") | ||
|
||
set(output_file "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${output_libname}${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
|
||
if (WIN32) | ||
|
||
foreach (target IN LISTS static_libs) | ||
list(APPEND lib_files $<TARGET_FILE:${target}>) | ||
endforeach () | ||
|
||
add_custom_command( | ||
COMMAND ${CMAKE_AR} /NOLOGO /OUT:${output_file} ${lib_files} | ||
OUTPUT ${output_file} | ||
DEPENDS ${static_libs} | ||
VERBATIM) | ||
|
||
endif() | ||
|
||
add_custom_target(${output_lib} ALL DEPENDS ${output_file}) | ||
|
||
endfunction() | ||
|
||
create_bundled_lib(libdawn_static dawn_static webgpu_dawn libtint) |