mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-20 14:05:23 +01:00
build: Produce a usable static kernel library
Since the move to cmake, the kernel static library that is installed after a cmake --install build is unusable. It lacks symbols for the internal libraries, besides those defined in the kernel library target. This is because cmake, unlike the libtool archiver, does not combine multiple static libraries into a single static library on installation. This is likely an intentional design choice, since there were a bunch of caveats to the way libtool calculated these libraries. Fix this problem by installing all the required libraries. The user must then link all of them along with the bitcoin kernel library.
This commit is contained in:
parent
f640b323bd
commit
45be32f838
1 changed files with 26 additions and 0 deletions
|
@ -98,6 +98,32 @@ set_target_properties(bitcoinkernel PROPERTIES
|
|||
CXX_VISIBILITY_PRESET default
|
||||
)
|
||||
|
||||
# When building the static library, install all static libraries the
|
||||
# bitcoinkernel depends on.
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
# Recursively get all the static libraries a target depends on and put them in libs_out
|
||||
function(get_target_static_link_libs target libs_out)
|
||||
get_target_property(linked_libraries ${target} LINK_LIBRARIES)
|
||||
foreach(dep ${linked_libraries})
|
||||
if(TARGET ${dep})
|
||||
get_target_property(dep_type ${dep} TYPE)
|
||||
if(dep_type STREQUAL "STATIC_LIBRARY")
|
||||
list(APPEND ${libs_out} ${dep})
|
||||
get_target_static_link_libs(${dep} ${libs_out})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${libs_out} ${${libs_out}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(all_kernel_static_link_libs "")
|
||||
get_target_static_link_libs(bitcoinkernel all_kernel_static_link_libs)
|
||||
|
||||
foreach(lib ${all_kernel_static_link_libs})
|
||||
install(TARGETS ${lib} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS bitcoinkernel
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
|
|
Loading…
Add table
Reference in a new issue