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
This commit is contained in:
Ryan Ofsky
2025-01-17 11:44:46 -05:00
parent c540ede1cb
commit cd97905ebc
9 changed files with 19 additions and 13 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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}")

View File

@@ -367,7 +367,7 @@ if(ENABLE_IPC AND BUILD_DAEMON)
bitcoin_ipc
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
)
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()

View File

@@ -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)

View File

@@ -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()

View File

@@ -45,4 +45,4 @@ if(WIN32 AND VCPKG_TARGET_TRIPLET)
)
endif()
install_binary_component(test_bitcoin-qt)
install_binary_component(test_bitcoin-qt INTERNAL)

View File

@@ -213,4 +213,4 @@ endfunction()
add_all_test_targets()
install_binary_component(test_bitcoin)
install_binary_component(test_bitcoin INTERNAL)