Skip to content

Commit 73e2ec1

Browse files
committed
Merge bitcoin#31844: cmake: add a component for each binary
9b033be cmake: rename Kernel component to bitcoinkernel for consistency (Cory Fields) 2e0c925 cmake: add and use install_binary_component (Cory Fields) 0264c5d cmake: use per-target components for bitcoin-qt and bitcoin-gui (Cory Fields) fb0546b ci: don't try to install for a fuzz build (Cory Fields) Pull request description: This makes it possible to build/install only the desired binaries regardless of the configuration. For consistency, the component names match the binary names. `Kernel` and `GUI` have been renamed. Additionally it fixes bitcoin#31762 by installing only the manpages for the configured targets (and includes them in the component installs for each). Also fixes bitcoin#31745. Alternative to bitcoin#31765 which is (imo) more correct/thorough. Can be tested using (for ex): ```bash $ cmake -B build $ cmake --build build -t bitcoind -t bitcoin-cli $ cmake --install build --component bitcoind $ cmake --install build --component bitcoin-cli ``` ACKs for top commit: hebasto: ACK 9b033be. TheCharlatan: Re-ACK 9b033be stickies-v: re-ACK 9b033be Tree-SHA512: fd4818e76f190dbeafbf0c246b466f829771902c9d6d7111ed917093b811c8a5536a4a45e20708f73e7f581d6cb77c8e61cfa69e065788dcf0886792f553a355
2 parents 7bbd761 + 9b033be commit 73e2ec1

File tree

10 files changed

+48
-46
lines changed

10 files changed

+48
-46
lines changed

ci/test/00_setup_env_mac_native_fuzz.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ export OSX_SDK=""
1414
export RUN_UNIT_TESTS=false
1515
export RUN_FUNCTIONAL_TESTS=false
1616
export RUN_FUZZ_TESTS=true
17+
export GOAL="all"

ci/test/00_setup_env_native_fuzz.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export NO_DEPENDS=1
1414
export RUN_UNIT_TESTS=false
1515
export RUN_FUNCTIONAL_TESTS=false
1616
export RUN_FUZZ_TESTS=true
17-
export GOAL="install"
17+
export GOAL="all"
1818
export CI_CONTAINER_CAP="--cap-add SYS_PTRACE" # If run with (ASan + LSan), the container needs access to ptrace (https://github.com/google/sanitizers/issues/764)
1919
export BITCOIN_CONFIG="\
2020
-DBUILD_FOR_FUZZING=ON \
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) 2025-present The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or https://opensource.org/license/mit/.
4+
5+
include_guard(GLOBAL)
6+
include(GNUInstallDirs)
7+
8+
function(install_binary_component component)
9+
cmake_parse_arguments(PARSE_ARGV 1
10+
IC # prefix
11+
"HAS_MANPAGE" # options
12+
"" # one_value_keywords
13+
"" # multi_value_keywords
14+
)
15+
set(target_name ${component})
16+
install(TARGETS ${target_name}
17+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
18+
COMPONENT ${component}
19+
)
20+
if(INSTALL_MAN AND IC_HAS_MANPAGE)
21+
install(FILES ${PROJECT_SOURCE_DIR}/doc/man/${target_name}.1
22+
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
23+
COMPONENT ${component}
24+
)
25+
endif()
26+
endfunction()

cmake/module/Maintenance.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function(add_macos_deploy_target)
8484

8585
add_custom_command(
8686
OUTPUT ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt
87-
COMMAND ${CMAKE_COMMAND} --install ${PROJECT_BINARY_DIR} --config $<CONFIG> --component GUI --prefix ${macos_app}/Contents/MacOS --strip
87+
COMMAND ${CMAKE_COMMAND} --install ${PROJECT_BINARY_DIR} --config $<CONFIG> --component bitcoin-qt --prefix ${macos_app}/Contents/MacOS --strip
8888
COMMAND ${CMAKE_COMMAND} -E rename ${macos_app}/Contents/MacOS/bin/$<TARGET_FILE_NAME:bitcoin-qt> ${macos_app}/Contents/MacOS/Bitcoin-Qt
8989
COMMAND ${CMAKE_COMMAND} -E rm -rf ${macos_app}/Contents/MacOS/bin
9090
VERBATIM

src/CMakeLists.txt

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Distributed under the MIT software license, see the accompanying
33
# file COPYING or https://opensource.org/license/mit/.
44

5-
include(GNUInstallDirs)
65
include(AddWindowsResources)
76

87
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
170169
$<$<PLATFORM_ID:Windows>:ws2_32>
171170
)
172171

172+
include(InstallBinaryComponent)
173173

174-
set(installable_targets)
175174
if(ENABLE_WALLET)
176175
add_subdirectory(wallet)
177176

@@ -189,7 +188,7 @@ if(ENABLE_WALLET)
189188
bitcoin_util
190189
Boost::headers
191190
)
192-
list(APPEND installable_targets bitcoin-wallet)
191+
install_binary_component(bitcoin-wallet HAS_MANPAGE)
193192
endif()
194193
endif()
195194

@@ -318,7 +317,7 @@ if(BUILD_DAEMON)
318317
bitcoin_node
319318
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
320319
)
321-
list(APPEND installable_targets bitcoind)
320+
install_binary_component(bitcoind HAS_MANPAGE)
322321
endif()
323322
if(WITH_MULTIPROCESS AND BUILD_DAEMON)
324323
add_executable(bitcoin-node
@@ -331,7 +330,7 @@ if(WITH_MULTIPROCESS AND BUILD_DAEMON)
331330
bitcoin_ipc
332331
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
333332
)
334-
list(APPEND installable_targets bitcoin-node)
333+
install_binary_component(bitcoin-node)
335334
endif()
336335

337336
if(WITH_MULTIPROCESS AND BUILD_TESTS)
@@ -374,7 +373,7 @@ if(BUILD_CLI)
374373
libevent::core
375374
libevent::extra
376375
)
377-
list(APPEND installable_targets bitcoin-cli)
376+
install_binary_component(bitcoin-cli HAS_MANPAGE)
378377
endif()
379378

380379

@@ -387,7 +386,7 @@ if(BUILD_TX)
387386
bitcoin_util
388387
univalue
389388
)
390-
list(APPEND installable_targets bitcoin-tx)
389+
install_binary_component(bitcoin-tx HAS_MANPAGE)
391390
endif()
392391

393392

@@ -399,7 +398,7 @@ if(BUILD_UTIL)
399398
bitcoin_common
400399
bitcoin_util
401400
)
402-
list(APPEND installable_targets bitcoin-util)
401+
install_binary_component(bitcoin-util HAS_MANPAGE)
403402
endif()
404403

405404

@@ -445,17 +444,3 @@ endif()
445444
if(BUILD_FUZZ_BINARY)
446445
add_subdirectory(test/fuzz)
447446
endif()
448-
449-
450-
install(TARGETS ${installable_targets}
451-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
452-
)
453-
unset(installable_targets)
454-
455-
if(INSTALL_MAN)
456-
# TODO: these stubs are no longer needed. man pages should be generated at install time.
457-
install(DIRECTORY ../doc/man/
458-
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
459-
FILES_MATCHING PATTERN *.1
460-
)
461-
endif()

src/bench/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,4 @@ add_test(NAME bench_sanity_check_high_priority
8181
COMMAND bench_bitcoin -sanity-check -priority-level=high
8282
)
8383

84-
install(TARGETS bench_bitcoin
85-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
86-
)
84+
install_binary_component(bench_bitcoin)

src/kernel/CMakeLists.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Distributed under the MIT software license, see the accompanying
33
# file COPYING or https://opensource.org/license/mit/.
44

5+
include(GNUInstallDirs)
6+
57
# TODO: libbitcoinkernel is a work in progress consensus engine
68
# library, as more and more modules are decoupled from the
79
# consensus engine, this list will shrink to only those
@@ -121,24 +123,23 @@ if(NOT BUILD_SHARED_LIBS)
121123
set(all_kernel_static_link_libs "")
122124
get_target_static_link_libs(bitcoinkernel all_kernel_static_link_libs)
123125

124-
install(TARGETS ${all_kernel_static_link_libs} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Kernel)
126+
install(TARGETS ${all_kernel_static_link_libs} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT bitcoinkernel)
125127
list(TRANSFORM all_kernel_static_link_libs PREPEND "-l")
126128
# LIBS_PRIVATE is substituted in the pkg-config file.
127129
list(JOIN all_kernel_static_link_libs " " LIBS_PRIVATE)
128130
endif()
129131

130132
configure_file(${PROJECT_SOURCE_DIR}/libbitcoinkernel.pc.in ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc @ONLY)
131-
install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT Kernel)
133+
install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT bitcoinkernel)
132134

133-
include(GNUInstallDirs)
134135
install(TARGETS bitcoinkernel
135136
RUNTIME
136137
DESTINATION ${CMAKE_INSTALL_BINDIR}
137-
COMPONENT Kernel
138+
COMPONENT bitcoinkernel
138139
LIBRARY
139140
DESTINATION ${CMAKE_INSTALL_LIBDIR}
140-
COMPONENT Kernel
141+
COMPONENT bitcoinkernel
141142
ARCHIVE
142143
DESTINATION ${CMAKE_INSTALL_LIBDIR}
143-
COMPONENT Kernel
144+
COMPONENT bitcoinkernel
144145
)

src/qt/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ target_link_libraries(bitcoin-qt
236236
)
237237

238238
import_plugins(bitcoin-qt)
239-
set(installable_targets bitcoin-qt)
239+
install_binary_component(bitcoin-qt HAS_MANPAGE)
240240
if(WIN32)
241241
set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE)
242242
endif()
@@ -253,17 +253,12 @@ if(WITH_MULTIPROCESS)
253253
bitcoin_ipc
254254
)
255255
import_plugins(bitcoin-gui)
256-
list(APPEND installable_targets bitcoin-gui)
256+
install_binary_component(bitcoin-gui)
257257
if(WIN32)
258258
set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE)
259259
endif()
260260
endif()
261261

262-
install(TARGETS ${installable_targets}
263-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
264-
COMPONENT GUI
265-
)
266-
267262
if(BUILD_GUI_TESTS)
268263
add_subdirectory(test)
269264
endif()

src/qt/test/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,4 @@ if(WIN32 AND VCPKG_TARGET_TRIPLET)
4545
)
4646
endif()
4747

48-
install(TARGETS test_bitcoin-qt
49-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
50-
)
48+
install_binary_component(test_bitcoin-qt)

src/test/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,4 @@ endfunction()
214214

215215
add_all_test_targets()
216216

217-
install(TARGETS test_bitcoin
218-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
219-
)
217+
install_binary_component(test_bitcoin)

0 commit comments

Comments
 (0)