From fb0546b1c5ebb858605bef4c9fa001782e0ab213 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 11 Feb 2025 22:42:47 +0000 Subject: [PATCH 1/4] ci: don't try to install for a fuzz build Currently the manpages are installed, but that is a bug. An upcoming commit will avoid installing manpages for targets that aren't configured, which removes the "install" target for fuzz builds. --- ci/test/00_setup_env_mac_native_fuzz.sh | 1 + ci/test/00_setup_env_native_fuzz.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/test/00_setup_env_mac_native_fuzz.sh b/ci/test/00_setup_env_mac_native_fuzz.sh index 1a453a4353f..cacf2423ac3 100755 --- a/ci/test/00_setup_env_mac_native_fuzz.sh +++ b/ci/test/00_setup_env_mac_native_fuzz.sh @@ -14,3 +14,4 @@ export OSX_SDK="" export RUN_UNIT_TESTS=false export RUN_FUNCTIONAL_TESTS=false export RUN_FUZZ_TESTS=true +export GOAL="all" diff --git a/ci/test/00_setup_env_native_fuzz.sh b/ci/test/00_setup_env_native_fuzz.sh index 1b5a27bb6cd..84e57311dcd 100755 --- a/ci/test/00_setup_env_native_fuzz.sh +++ b/ci/test/00_setup_env_native_fuzz.sh @@ -14,7 +14,7 @@ export NO_DEPENDS=1 export RUN_UNIT_TESTS=false export RUN_FUNCTIONAL_TESTS=false export RUN_FUZZ_TESTS=true -export GOAL="install" +export GOAL="all" 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) export BITCOIN_CONFIG="\ -DBUILD_FOR_FUZZING=ON \ From 0264c5d86c74c25407f0a07326d6f8722665fe74 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 11 Feb 2025 18:26:36 +0000 Subject: [PATCH 2/4] cmake: use per-target components for bitcoin-qt and bitcoin-gui This makes the usage consistent with the next commit, which will add a per-target component for each binary. --- cmake/module/Maintenance.cmake | 2 +- src/qt/CMakeLists.txt | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmake/module/Maintenance.cmake b/cmake/module/Maintenance.cmake index 61251d24397..bc3868184bf 100644 --- a/cmake/module/Maintenance.cmake +++ b/cmake/module/Maintenance.cmake @@ -103,7 +103,7 @@ function(add_macos_deploy_target) add_custom_command( OUTPUT ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt - COMMAND ${CMAKE_COMMAND} --install ${PROJECT_BINARY_DIR} --config $ --component GUI --prefix ${macos_app}/Contents/MacOS --strip + COMMAND ${CMAKE_COMMAND} --install ${PROJECT_BINARY_DIR} --config $ --component bitcoin-qt --prefix ${macos_app}/Contents/MacOS --strip COMMAND ${CMAKE_COMMAND} -E rename ${macos_app}/Contents/MacOS/bin/$ ${macos_app}/Contents/MacOS/Bitcoin-Qt COMMAND ${CMAKE_COMMAND} -E rm -rf ${macos_app}/Contents/MacOS/bin VERBATIM diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index a1f39037f22..04099faa977 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -236,7 +236,10 @@ target_link_libraries(bitcoin-qt ) import_plugins(bitcoin-qt) -set(installable_targets bitcoin-qt) +install(TARGETS bitcoin-qt + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT bitcoin-qt +) if(WIN32) set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE) endif() @@ -253,17 +256,15 @@ if(WITH_MULTIPROCESS) bitcoin_ipc ) import_plugins(bitcoin-gui) - list(APPEND installable_targets bitcoin-gui) + install(TARGETS bitcoin-gui + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT bitcoin-gui + ) if(WIN32) set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE) endif() endif() -install(TARGETS ${installable_targets} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT GUI -) - if(BUILD_GUI_TESTS) add_subdirectory(test) endif() From 2e0c92558e96b43351312d8fd403a20b9795acd4 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 11 Feb 2025 18:23:44 +0000 Subject: [PATCH 3/4] 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. --- cmake/module/InstallBinaryComponent.cmake | 26 ++++++++++++++++++++ src/CMakeLists.txt | 29 ++++++----------------- src/bench/CMakeLists.txt | 4 +--- src/kernel/CMakeLists.txt | 3 ++- src/qt/CMakeLists.txt | 10 ++------ src/qt/test/CMakeLists.txt | 4 +--- src/test/CMakeLists.txt | 4 +--- 7 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 cmake/module/InstallBinaryComponent.cmake diff --git a/cmake/module/InstallBinaryComponent.cmake b/cmake/module/InstallBinaryComponent.cmake new file mode 100644 index 00000000000..c7b2ed9ae6a --- /dev/null +++ b/cmake/module/InstallBinaryComponent.cmake @@ -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() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c42359d2d5..07544f59cfa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,6 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or https://opensource.org/license/mit/. -include(GNUInstallDirs) include(AddWindowsResources) 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 $<$:ws2_32> ) +include(InstallBinaryComponent) -set(installable_targets) if(ENABLE_WALLET) add_subdirectory(wallet) @@ -189,7 +188,7 @@ if(ENABLE_WALLET) bitcoin_util Boost::headers ) - list(APPEND installable_targets bitcoin-wallet) + install_binary_component(bitcoin-wallet HAS_MANPAGE) endif() endif() @@ -318,7 +317,7 @@ if(BUILD_DAEMON) bitcoin_node $ ) - list(APPEND installable_targets bitcoind) + install_binary_component(bitcoind HAS_MANPAGE) endif() if(WITH_MULTIPROCESS AND BUILD_DAEMON) add_executable(bitcoin-node @@ -331,7 +330,7 @@ if(WITH_MULTIPROCESS AND BUILD_DAEMON) bitcoin_ipc $ ) - list(APPEND installable_targets bitcoin-node) + install_binary_component(bitcoin-node) endif() if(WITH_MULTIPROCESS AND BUILD_TESTS) @@ -374,7 +373,7 @@ if(BUILD_CLI) libevent::core libevent::extra ) - list(APPEND installable_targets bitcoin-cli) + install_binary_component(bitcoin-cli HAS_MANPAGE) endif() @@ -387,7 +386,7 @@ if(BUILD_TX) bitcoin_util univalue ) - list(APPEND installable_targets bitcoin-tx) + install_binary_component(bitcoin-tx HAS_MANPAGE) endif() @@ -399,7 +398,7 @@ if(BUILD_UTIL) bitcoin_common bitcoin_util ) - list(APPEND installable_targets bitcoin-util) + install_binary_component(bitcoin-util HAS_MANPAGE) endif() @@ -445,17 +444,3 @@ endif() if(BUILD_FUZZ_BINARY) add_subdirectory(test/fuzz) 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() diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt index c55bbb1e05f..43b0dcdabe6 100644 --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -81,6 +81,4 @@ add_test(NAME bench_sanity_check_high_priority COMMAND bench_bitcoin -sanity-check -priority-level=high ) -install(TARGETS bench_bitcoin - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +install_binary_component(bench_bitcoin) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 2e07ba042a4..ac04e7bc88b 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -2,6 +2,8 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or https://opensource.org/license/mit/. +include(GNUInstallDirs) + # TODO: libbitcoinkernel is a work in progress consensus engine # library, as more and more modules are decoupled from the # 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) install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT Kernel) -include(GNUInstallDirs) install(TARGETS bitcoinkernel RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 04099faa977..7fbbd81c415 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -236,10 +236,7 @@ target_link_libraries(bitcoin-qt ) import_plugins(bitcoin-qt) -install(TARGETS bitcoin-qt - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT bitcoin-qt -) +install_binary_component(bitcoin-qt HAS_MANPAGE) if(WIN32) set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE) endif() @@ -256,10 +253,7 @@ if(WITH_MULTIPROCESS) bitcoin_ipc ) import_plugins(bitcoin-gui) - install(TARGETS bitcoin-gui - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT bitcoin-gui - ) + install_binary_component(bitcoin-gui) if(WIN32) set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE) endif() diff --git a/src/qt/test/CMakeLists.txt b/src/qt/test/CMakeLists.txt index e1e617661b4..3acdfeade34 100644 --- a/src/qt/test/CMakeLists.txt +++ b/src/qt/test/CMakeLists.txt @@ -45,6 +45,4 @@ if(WIN32 AND VCPKG_TARGET_TRIPLET) ) endif() -install(TARGETS test_bitcoin-qt - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +install_binary_component(test_bitcoin-qt) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 859b9132067..6523407e912 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -213,6 +213,4 @@ endfunction() add_all_test_targets() -install(TARGETS test_bitcoin - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +install_binary_component(test_bitcoin) From 9b033bebb18dfd609c02736292f37cc6589fcc8d Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 11 Feb 2025 18:36:45 +0000 Subject: [PATCH 4/4] cmake: rename Kernel component to bitcoinkernel for consistency --- src/kernel/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index ac04e7bc88b..9dae4b88111 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -123,23 +123,23 @@ 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) + install(TARGETS ${all_kernel_static_link_libs} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT bitcoinkernel) list(TRANSFORM all_kernel_static_link_libs PREPEND "-l") # LIBS_PRIVATE is substituted in the pkg-config file. 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" COMPONENT Kernel) +install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT bitcoinkernel) install(TARGETS bitcoinkernel RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT Kernel + COMPONENT bitcoinkernel LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT Kernel + COMPONENT bitcoinkernel ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT Kernel + COMPONENT bitcoinkernel )