From 45bfd97ec7c9991f41673d79b01277bfd940e64e 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/ Currently when "make install" or "cmake --install" are run, various internal binaries that are confusing and not typically useful and installed to `${CMAKE_INSTALL_PREFIX}/bin` and can wind up on the system PATH. This PR moves internal binaries out of bin/ into libexec/ where they will still be accessible but will not be automatically placed on the PATH or be confused with more useful binaries. The PR also adds an install rule for the bitcoin-chainstate binary. After this PR binaries installed to bin/ are: - bitcoin-cli - bitcoind - bitcoin-qt - bitcoin-tx - bitcoin-util - bitcoin-wallet And binaries installed to libexec/ are: - bench_bitcoin - bitcoin-gui - bitcoin-node - test_bitcoin - test_bitcoin-qt In the future if #31375 gets merged, there will be a new `bitcoin` wrapper executable in bin/ that can be used to call other binaries, and with that present, we could consider moving other binaries from bin/ to libexec/ and recommending that most users should use the wrapper instead of calling the different utilities directly. But this PR should make sense with or without #31375. --- ci/test/03_test_script.sh | 2 +- cmake/module/InstallBinaryComponent.cmake | 9 +++++++-- 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 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index bd5c86bfbe7..22498f21dbe 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -149,7 +149,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_OUTDIR}"/libexec/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..9bfe4d52632 100644 --- a/cmake/module/InstallBinaryComponent.cmake +++ b/cmake/module/InstallBinaryComponent.cmake @@ -8,13 +8,18 @@ include(GNUInstallDirs) function(install_binary_component component) cmake_parse_arguments(PARSE_ARGV 1 IC # prefix - "HAS_MANPAGE" # options + "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/src/CMakeLists.txt b/src/CMakeLists.txt index 07544f59cfa..8051e33da63 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -330,7 +330,7 @@ if(WITH_MULTIPROCESS AND BUILD_DAEMON) bitcoin_ipc $ ) - install_binary_component(bitcoin-node) + install_binary_component(bitcoin-node INTERNAL) endif() if(WITH_MULTIPROCESS AND BUILD_TESTS) @@ -429,6 +429,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 43b0dcdabe6..4e7879ec7ff 100644 --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -81,4 +81,4 @@ add_test(NAME bench_sanity_check_high_priority COMMAND bench_bitcoin -sanity-check -priority-level=high ) -install_binary_component(bench_bitcoin) +install_binary_component(bench_bitcoin INTERNAL) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 7fbbd81c415..2074b4e1e8d 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -253,7 +253,7 @@ if(WITH_MULTIPROCESS) 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 3acdfeade34..899e58c99b3 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 b0dd27894d3..7db3b2a6c4e 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -214,4 +214,4 @@ endfunction() add_all_test_targets() -install_binary_component(test_bitcoin) +install_binary_component(test_bitcoin INTERNAL)