mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
cmake: add and use install_binary_component
Add a separate component for each binary for fine-grained installation options. Also install the man pages for only for the targets enabled.
This commit is contained in:
parent
0264c5d86c
commit
2e0c92558e
7 changed files with 40 additions and 40 deletions
26
cmake/module/InstallBinaryComponent.cmake
Normal file
26
cmake/module/InstallBinaryComponent.cmake
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Copyright (c) 2025-present The Bitcoin Core developers
|
||||||
|
# Distributed under the MIT software license, see the accompanying
|
||||||
|
# file COPYING or https://opensource.org/license/mit/.
|
||||||
|
|
||||||
|
include_guard(GLOBAL)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
function(install_binary_component component)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 1
|
||||||
|
IC # prefix
|
||||||
|
"HAS_MANPAGE" # options
|
||||||
|
"" # one_value_keywords
|
||||||
|
"" # multi_value_keywords
|
||||||
|
)
|
||||||
|
set(target_name ${component})
|
||||||
|
install(TARGETS ${target_name}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
COMPONENT ${component}
|
||||||
|
)
|
||||||
|
if(INSTALL_MAN AND IC_HAS_MANPAGE)
|
||||||
|
install(FILES ${PROJECT_SOURCE_DIR}/doc/man/${target_name}.1
|
||||||
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
|
||||||
|
COMPONENT ${component}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
|
@ -2,7 +2,6 @@
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or https://opensource.org/license/mit/.
|
# file COPYING or https://opensource.org/license/mit/.
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
include(AddWindowsResources)
|
include(AddWindowsResources)
|
||||||
|
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in bitcoin-build-config.h USE_SOURCE_PERMISSIONS @ONLY)
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in bitcoin-build-config.h USE_SOURCE_PERMISSIONS @ONLY)
|
||||||
|
@ -170,8 +169,8 @@ target_link_libraries(bitcoin_common
|
||||||
$<$<PLATFORM_ID:Windows>:ws2_32>
|
$<$<PLATFORM_ID:Windows>:ws2_32>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
include(InstallBinaryComponent)
|
||||||
|
|
||||||
set(installable_targets)
|
|
||||||
if(ENABLE_WALLET)
|
if(ENABLE_WALLET)
|
||||||
add_subdirectory(wallet)
|
add_subdirectory(wallet)
|
||||||
|
|
||||||
|
@ -189,7 +188,7 @@ if(ENABLE_WALLET)
|
||||||
bitcoin_util
|
bitcoin_util
|
||||||
Boost::headers
|
Boost::headers
|
||||||
)
|
)
|
||||||
list(APPEND installable_targets bitcoin-wallet)
|
install_binary_component(bitcoin-wallet HAS_MANPAGE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -318,7 +317,7 @@ if(BUILD_DAEMON)
|
||||||
bitcoin_node
|
bitcoin_node
|
||||||
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
|
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
|
||||||
)
|
)
|
||||||
list(APPEND installable_targets bitcoind)
|
install_binary_component(bitcoind HAS_MANPAGE)
|
||||||
endif()
|
endif()
|
||||||
if(WITH_MULTIPROCESS AND BUILD_DAEMON)
|
if(WITH_MULTIPROCESS AND BUILD_DAEMON)
|
||||||
add_executable(bitcoin-node
|
add_executable(bitcoin-node
|
||||||
|
@ -331,7 +330,7 @@ if(WITH_MULTIPROCESS AND BUILD_DAEMON)
|
||||||
bitcoin_ipc
|
bitcoin_ipc
|
||||||
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
|
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
|
||||||
)
|
)
|
||||||
list(APPEND installable_targets bitcoin-node)
|
install_binary_component(bitcoin-node)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_MULTIPROCESS AND BUILD_TESTS)
|
if(WITH_MULTIPROCESS AND BUILD_TESTS)
|
||||||
|
@ -374,7 +373,7 @@ if(BUILD_CLI)
|
||||||
libevent::core
|
libevent::core
|
||||||
libevent::extra
|
libevent::extra
|
||||||
)
|
)
|
||||||
list(APPEND installable_targets bitcoin-cli)
|
install_binary_component(bitcoin-cli HAS_MANPAGE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -387,7 +386,7 @@ if(BUILD_TX)
|
||||||
bitcoin_util
|
bitcoin_util
|
||||||
univalue
|
univalue
|
||||||
)
|
)
|
||||||
list(APPEND installable_targets bitcoin-tx)
|
install_binary_component(bitcoin-tx HAS_MANPAGE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -399,7 +398,7 @@ if(BUILD_UTIL)
|
||||||
bitcoin_common
|
bitcoin_common
|
||||||
bitcoin_util
|
bitcoin_util
|
||||||
)
|
)
|
||||||
list(APPEND installable_targets bitcoin-util)
|
install_binary_component(bitcoin-util HAS_MANPAGE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -445,17 +444,3 @@ endif()
|
||||||
if(BUILD_FUZZ_BINARY)
|
if(BUILD_FUZZ_BINARY)
|
||||||
add_subdirectory(test/fuzz)
|
add_subdirectory(test/fuzz)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
install(TARGETS ${installable_targets}
|
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
unset(installable_targets)
|
|
||||||
|
|
||||||
if(INSTALL_MAN)
|
|
||||||
# TODO: these stubs are no longer needed. man pages should be generated at install time.
|
|
||||||
install(DIRECTORY ../doc/man/
|
|
||||||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
|
|
||||||
FILES_MATCHING PATTERN *.1
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
|
@ -81,6 +81,4 @@ add_test(NAME bench_sanity_check_high_priority
|
||||||
COMMAND bench_bitcoin -sanity-check -priority-level=high
|
COMMAND bench_bitcoin -sanity-check -priority-level=high
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS bench_bitcoin
|
install_binary_component(bench_bitcoin)
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or https://opensource.org/license/mit/.
|
# file COPYING or https://opensource.org/license/mit/.
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# TODO: libbitcoinkernel is a work in progress consensus engine
|
# TODO: libbitcoinkernel is a work in progress consensus engine
|
||||||
# library, as more and more modules are decoupled from the
|
# library, as more and more modules are decoupled from the
|
||||||
# consensus engine, this list will shrink to only those
|
# consensus engine, this list will shrink to only those
|
||||||
|
@ -130,7 +132,6 @@ endif()
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/libbitcoinkernel.pc.in ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc @ONLY)
|
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" COMPONENT Kernel)
|
install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT Kernel)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
install(TARGETS bitcoinkernel
|
install(TARGETS bitcoinkernel
|
||||||
RUNTIME
|
RUNTIME
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
|
|
@ -236,10 +236,7 @@ target_link_libraries(bitcoin-qt
|
||||||
)
|
)
|
||||||
|
|
||||||
import_plugins(bitcoin-qt)
|
import_plugins(bitcoin-qt)
|
||||||
install(TARGETS bitcoin-qt
|
install_binary_component(bitcoin-qt HAS_MANPAGE)
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
COMPONENT bitcoin-qt
|
|
||||||
)
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE)
|
set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
@ -256,10 +253,7 @@ if(WITH_MULTIPROCESS)
|
||||||
bitcoin_ipc
|
bitcoin_ipc
|
||||||
)
|
)
|
||||||
import_plugins(bitcoin-gui)
|
import_plugins(bitcoin-gui)
|
||||||
install(TARGETS bitcoin-gui
|
install_binary_component(bitcoin-gui)
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
COMPONENT bitcoin-gui
|
|
||||||
)
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE)
|
set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -45,6 +45,4 @@ if(WIN32 AND VCPKG_TARGET_TRIPLET)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS test_bitcoin-qt
|
install_binary_component(test_bitcoin-qt)
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
|
@ -213,6 +213,4 @@ endfunction()
|
||||||
|
|
||||||
add_all_test_targets()
|
add_all_test_targets()
|
||||||
|
|
||||||
install(TARGETS test_bitcoin
|
install_binary_component(test_bitcoin)
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue