From cd97905ebc564b8b095099a28d1d5437951927c4 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Fri, 17 Jan 2025 11:44:46 -0500 Subject: [PATCH] cmake: Move internal binaries from bin/ to libexec/ This change moves binaries that are not typically invoked directly by users from the `bin/` directory to the `libexec/` directory in CMake installs and binary releases. The goal is to simplify the contents of `bin/` for end users while still making all binaries available when needed. After this change, the binaries remaining in `bin/` are: - bitcoin - bitcoin-cli - bitcoind - bitcoin-qt - bitcoin-tx - bitcoin-util - bitcoin-wallet And the binaries that are moved to `libexec/` are: - bench_bitcoin - bitcoin-chainstate(*) - bitcoin-gui(***) - bitcoin-node(***) - test_bitcoin(**) - test_bitcoin-qt (*) bitcoin-chainstate was previously missing an install rule and was actually not installed even when it was enabled. (**) test_bitcoin is the only libexec/ binary that is currently included in bitcoin binary releases. The others are only installed when building from source with relevant cmake options enabled. (***) bitcoin-node and bitcoin-gui are not currently built by default or included in binary releases but both of these changes are planned and implemented in #31802 --- ci/test/03_test_script.sh | 2 +- cmake/module/InstallBinaryComponent.cmake | 15 ++++++++++----- contrib/guix/libexec/codesign.sh | 2 +- contrib/macdeploy/detached-sig-create.sh | 2 +- src/CMakeLists.txt | 3 ++- src/bench/CMakeLists.txt | 2 +- src/qt/CMakeLists.txt | 2 +- src/qt/test/CMakeLists.txt | 2 +- src/test/CMakeLists.txt | 2 +- 9 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index 3394c50b8bd..d836a9efa7d 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -145,7 +145,7 @@ if [ "$RUN_UNIT_TESTS" = "true" ]; then fi if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then - DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" "${BASE_OUTDIR}"/bin/test_bitcoin --catch_system_errors=no -l test_suite + DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" "${BASE_BUILD_DIR}"/bin/test_bitcoin --catch_system_errors=no -l test_suite fi if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then diff --git a/cmake/module/InstallBinaryComponent.cmake b/cmake/module/InstallBinaryComponent.cmake index c7b2ed9ae6a..42bcd88efb4 100644 --- a/cmake/module/InstallBinaryComponent.cmake +++ b/cmake/module/InstallBinaryComponent.cmake @@ -7,14 +7,19 @@ include(GNUInstallDirs) function(install_binary_component component) cmake_parse_arguments(PARSE_ARGV 1 - IC # prefix - "HAS_MANPAGE" # options - "" # one_value_keywords - "" # multi_value_keywords + IC # prefix + "HAS_MANPAGE;INTERNAL" # options + "" # one_value_keywords + "" # multi_value_keywords ) set(target_name ${component}) + if(IC_INTERNAL) + set(runtime_dest ${CMAKE_INSTALL_LIBEXECDIR}) + else() + set(runtime_dest ${CMAKE_INSTALL_BINDIR}) + endif() install(TARGETS ${target_name} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${runtime_dest} COMPONENT ${component} ) if(INSTALL_MAN AND IC_HAS_MANPAGE) diff --git a/contrib/guix/libexec/codesign.sh b/contrib/guix/libexec/codesign.sh index 3a729371114..fe86065350e 100755 --- a/contrib/guix/libexec/codesign.sh +++ b/contrib/guix/libexec/codesign.sh @@ -110,7 +110,7 @@ mkdir -p "$DISTSRC" # Apply detached codesignatures (in-place) signapple apply dist/Bitcoin-Qt.app codesignatures/osx/"${HOST}"/dist/Bitcoin-Qt.app - find "${DISTNAME}" -wholename "*/bin/*" -type f | while read -r bin + find "${DISTNAME}" \( -wholename "*/bin/*" -o -wholename "*/libexec/*" \) -type f | while read -r bin do signapple apply "${bin}" "codesignatures/osx/${HOST}/${bin}.${ARCH}sign" done diff --git a/contrib/macdeploy/detached-sig-create.sh b/contrib/macdeploy/detached-sig-create.sh index 89094403b7f..b558784eff2 100755 --- a/contrib/macdeploy/detached-sig-create.sh +++ b/contrib/macdeploy/detached-sig-create.sh @@ -44,7 +44,7 @@ ${SIGNAPPLE} apply "${UNSIGNED_BUNDLE}" "${OUTROOT}/${BUNDLE_ROOT}/${BUNDLE_NAME ${SIGNAPPLE} notarize --detach "${OUTROOT}/${BUNDLE_ROOT}" --passphrase "${api_key_pass}" "$2" "$3" "${UNSIGNED_BUNDLE}" # Sign each binary -find . -maxdepth 3 -wholename "*/bin/*" -type f -exec realpath --relative-to=. {} \; | while read -r bin +find . -maxdepth 3 \( -wholename "*/bin/*" -o -wholename "*/libexec/*" \) -type f -exec realpath --relative-to=. {} \; | while read -r bin do bin_dir=$(dirname "${bin}") bin_name=$(basename "${bin}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 96a6790e612..eb8612c4285 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -367,7 +367,7 @@ if(ENABLE_IPC AND BUILD_DAEMON) bitcoin_ipc $ ) - install_binary_component(bitcoin-node) + install_binary_component(bitcoin-node INTERNAL) endif() if(ENABLE_IPC AND BUILD_TESTS) @@ -469,6 +469,7 @@ if(BUILD_UTIL_CHAINSTATE) core_interface bitcoinkernel ) + install_binary_component(bitcoin-chainstate INTERNAL) endif() diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt index 905187fbb00..0168589a6a0 100644 --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -83,4 +83,4 @@ add_test(NAME bench_sanity_check COMMAND bench_bitcoin -sanity-check ) -install_binary_component(bench_bitcoin) +install_binary_component(bench_bitcoin INTERNAL) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 6c853cbf2f8..ed7d9a49511 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -282,7 +282,7 @@ if(ENABLE_IPC) bitcoin_ipc ) import_plugins(bitcoin-gui) - install_binary_component(bitcoin-gui) + install_binary_component(bitcoin-gui INTERNAL) 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 cbfb144596b..8fe4ea68e26 100644 --- a/src/qt/test/CMakeLists.txt +++ b/src/qt/test/CMakeLists.txt @@ -45,4 +45,4 @@ if(WIN32 AND VCPKG_TARGET_TRIPLET) ) endif() -install_binary_component(test_bitcoin-qt) +install_binary_component(test_bitcoin-qt INTERNAL) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 6ce33621af8..6f00e2f2258 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -213,4 +213,4 @@ endfunction() add_all_test_targets() -install_binary_component(test_bitcoin) +install_binary_component(test_bitcoin INTERNAL)