From b27bf9700dbbfa9a0243815f78c8b62abe78d8bc Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Mon, 20 May 2024 21:10:46 +0100 Subject: [PATCH] cmake: Build `bitcoin-cli` executable --- CMakeLists.txt | 4 +++- src/CMakeLists.txt | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0b810fe0e3..99538918607 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module) #============================= # When adding a new option, end the with a full stop for consistency. option(BUILD_DAEMON "Build bitcoind executable." ON) +option(BUILD_CLI "Build bitcoin-cli executable." ON) option(WITH_CCACHE "Attempt to use ccache for compiling." ON) @@ -193,7 +194,7 @@ target_link_libraries(core_interface INTERFACE include(AddBoostIfNeeded) add_boost_if_needed() -if(BUILD_DAEMON) +if(BUILD_DAEMON OR BUILD_CLI) find_package(Libevent 2.1.8 MODULE REQUIRED) endif() @@ -228,6 +229,7 @@ message("Configure summary") message("=================") message("Executables:") message(" bitcoind ............................ ${BUILD_DAEMON}") +message(" bitcoin-cli ......................... ${BUILD_CLI}") message("") message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}") include(FlagsSummary) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 772ce88cddd..1189f2f42ce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -262,3 +262,27 @@ if(BUILD_DAEMON) bitcoin_node ) endif() + + +add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL + compat/stdin.cpp + rpc/client.cpp +) +target_link_libraries(bitcoin_cli + PUBLIC + core_interface + univalue +) + + +# Bitcoin Core RPC client +if(BUILD_CLI) + add_executable(bitcoin-cli bitcoin-cli.cpp) + target_link_libraries(bitcoin-cli + core_interface + bitcoin_cli + bitcoin_common + bitcoin_util + $ + ) +endif()