Merge bitcoin/bitcoin#31078: build: Fix kernel static lib component install

82e16e6983 cmake: Refactor install kernel dependencies (Hennadii Stepanov)
42e6277987 build: Add static libraries to Kernel install component (TheCharlatan)

Pull request description:

  Fixes the installation of the pkgconfig file and the static library when installing only the `Kernel` component.

  This is a followup to fix #30835 and #30814, which were merged shortly after one another, but are interrelated. Can be tested with:
  ```
  cmake -B build -DBUILD_SHARED_LIBS=OFF -DBUILD_KERNEL_LIB=ON
  cmake --build build --target bitcoinkernel
  cmake --install build --component Kernel
  ```

ACKs for top commit:
  hebasto:
    ACK 82e16e6983, tested on Ubuntu 23.10.
  fanquake:
    ACK 82e16e6983

Tree-SHA512: 07c18a341d4464e489c28fb262600338f1711248309ffb2af0ef3ab1abf06f10873c435895b63010e0be8e44af77046324896dfd872479792aa049831606dc45
This commit is contained in:
merge-script 2024-10-24 09:55:19 +01:00
commit 7290bc61c0
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -120,18 +120,14 @@ if(NOT BUILD_SHARED_LIBS)
set(all_kernel_static_link_libs "")
get_target_static_link_libs(bitcoinkernel all_kernel_static_link_libs)
install(TARGETS ${all_kernel_static_link_libs} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Kernel)
list(TRANSFORM all_kernel_static_link_libs PREPEND "-l")
# LIBS_PRIVATE is substituted in the pkg-config file.
set(LIBS_PRIVATE "")
foreach(lib ${all_kernel_static_link_libs})
install(TARGETS ${lib} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
string(APPEND LIBS_PRIVATE " -l${lib}")
endforeach()
string(STRIP "${LIBS_PRIVATE}" LIBS_PRIVATE)
list(JOIN all_kernel_static_link_libs " " LIBS_PRIVATE)
endif()
configure_file(${PROJECT_SOURCE_DIR}/libbitcoinkernel.pc.in ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT Kernel)
include(GNUInstallDirs)
install(TARGETS bitcoinkernel