From 6a7943a9e1a53571acb02557942a0ee2ef145300 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 7 Jun 2022 16:16:18 +0200 Subject: [PATCH] cmake: Build `bitcoin_wallet` static library --- CMakeLists.txt | 1 + src/CMakeLists.txt | 13 ++++++-- src/wallet/CMakeLists.txt | 63 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/wallet/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 34758294bed97..9f4ef2b31a228 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,7 @@ option(BUILD_DAEMON "Build bitcoind" ON) option(BUILD_CLI "Build bitcoin-cli" ON) option(BUILD_BITCOINCONSENSUS_LIB "Build bitcoinconsensus shared library" ON) option(BUILD_BITCOINKERNEL_LIB "Build experimental bitcoinkernel shared library" ON) +option(ENABLE_WALLET "Enable wallet" ON) if(BUILD_DAEMON OR BUILD_CLI OR BUILD_BITCOINKERNEL_LIB) # Find Boost headers only. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8131ebae4359a..2f199e6de372a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,9 @@ add_subdirectory(crypto) add_subdirectory(util) +if(ENABLE_WALLET) + add_subdirectory(wallet) +endif() # Home for common functionality shared by different executables and libraries. # Similar to `bitcoin_util` library, but higher-level. @@ -155,9 +158,12 @@ target_sources(bitcoin_node validation.cpp validationinterface.cpp versionbits.cpp - - dummywallet.cpp ) +if(ENABLE_WALLET) + target_sources(bitcoin_node PRIVATE wallet/init.cpp) +else() + target_sources(bitcoin_node PRIVATE dummywallet.cpp) +endif() target_include_directories(bitcoin_node PUBLIC @@ -183,6 +189,9 @@ if(BUILD_DAEMON) init/bitcoind.cpp ) + if(ENABLE_WALLET) + target_link_libraries(bitcoind PRIVATE bitcoin_wallet) + endif() target_link_libraries(bitcoind PRIVATE bitcoin_node diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt new file mode 100644 index 0000000000000..3490ad53f233b --- /dev/null +++ b/src/wallet/CMakeLists.txt @@ -0,0 +1,63 @@ +# Copyright (c) 2022 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +option(USE_SQLITE "Enable SQLite wallet support" ON) +option(USE_BDB "Enable Berkeley DB wallet support" OFF) + +if(USE_BDB) + message(WARNING "Berkeley DB wallet support has not been implemented yet, thus it will be disabled.") + set(USE_BDB OFF) +endif() + +if(NOT USE_SQLITE AND NOT USE_BDB) + message(FATAL_ERROR "None of USE_SQLITE and USE_BDB are enabled") +endif() + +# Wallet functionality used by bitcoind and bitcoin-wallet executables. +add_library(bitcoin_wallet STATIC EXCLUDE_FROM_ALL) +target_sources(bitcoin_wallet + PRIVATE + coincontrol.cpp + coinselection.cpp + context.cpp + crypter.cpp + db.cpp + dump.cpp + external_signer_scriptpubkeyman.cpp + feebumper.cpp + fees.cpp + interfaces.cpp + load.cpp + receive.cpp + rpc/addresses.cpp + rpc/backup.cpp + rpc/coins.cpp + rpc/encrypt.cpp + rpc/spend.cpp + rpc/signmessage.cpp + rpc/transactions.cpp + rpc/util.cpp + rpc/wallet.cpp + scriptpubkeyman.cpp + spend.cpp + transaction.cpp + wallet.cpp + walletdb.cpp + walletutil.cpp +) +target_include_directories(bitcoin_wallet + PUBLIC + $/src +) +target_link_libraries(bitcoin_wallet + PRIVATE + univalue + Boost::headers +) +if(USE_SQLITE) + pkg_check_modules(sqlite REQUIRED sqlite3>=3.7.17 IMPORTED_TARGET) + target_sources(bitcoin_wallet PRIVATE sqlite.cpp) + target_compile_definitions(bitcoin_wallet PRIVATE USE_SQLITE) + target_link_libraries(bitcoin_wallet PRIVATE PkgConfig::sqlite) +endif()