Skip to content

Commit

Permalink
Merge #164: cmake: Switch from tri-state options to boolean. Stage THREE
Browse files Browse the repository at this point in the history
2b4ad50 cmake [KILL 3-STATE]: Switch `WITH_{SQLITE,BDB}` to boolean (Hennadii Stepanov)

Pull request description:

  This PR is a continuation of #161 and #162 and tackles with the `WITH_SQLITE` and `WITH_BDB` options.

  For the latter the default value `OFF` is suggested.

  The #83 (comment):
  > Shouldn't `WITH_SQLITE=ON` imply `ENABLE_WALLET`? What (extra) does `ENABLE_WALLET` do here? I'm not sure we'll actually want to keep it as an option.

  has been addressed.

ACKs for top commit:
  TheCharlatan:
    ACK 2b4ad50

Tree-SHA512: 13d5bd16709ab557ee736696fe1d5d3fe64bae8cb77c000401c26b8be2deab0473474f7fa9bb958884ba3ab9c4d0b66e44766ca5c1c86d0fab3957642ec996b9
  • Loading branch information
hebasto committed May 4, 2024
2 parents 0be9840 + 2b4ad50 commit f918ccb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 58 deletions.
43 changes: 35 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ set(CMAKE_CXX_EXTENSIONS OFF)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module)

# Configurable options.
#=============================
# Configurable options
#=============================
include(CMakeDependentOption)
# When adding a new option, end the <help_text> with a full stop for consistency.
option(BUILD_DAEMON "Build bitcoind executable." ON)
option(BUILD_CLI "Build bitcoin-cli executable." ON)
Expand All @@ -67,20 +70,44 @@ option(BUILD_UTIL_CHAINSTATE "Build experimental bitcoin-chainstate executable."
option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." ${BUILD_UTIL_CHAINSTATE})

option(ENABLE_WALLET "Enable wallet." ON)
# TODO: These tri-state options will be removed and most features
# will become opt-in by default before merging into master.
include(TristateOption)
tristate_option(WITH_SQLITE "Enable SQLite wallet support." "if libsqlite3 is found." AUTO)
tristate_option(WITH_BDB "Enable Berkeley DB (BDB) wallet support." "if libdb_cxx is found." AUTO)
option(WARN_INCOMPATIBLE_BDB "Warn when using a Berkeley DB (BDB) version other than 4.8." ON)
include(CMakeDependentOption)
option(WITH_SQLITE "Enable SQLite wallet support." ${ENABLE_WALLET})
if(WITH_SQLITE)
if(VCPKG_TARGET_TRIPLET)
# Use of the `unofficial::` namespace is a vcpkg package manager convention.
find_package(unofficial-sqlite3 CONFIG REQUIRED)
else()
find_package(SQLite3 3.7.17 REQUIRED)
endif()
set(USE_SQLITE ON)
set(ENABLE_WALLET ON)
endif()
option(WITH_BDB "Enable Berkeley DB (BDB) wallet support." OFF)
cmake_dependent_option(WARN_INCOMPATIBLE_BDB "Warn when using a Berkeley DB (BDB) version other than 4.8." ON "WITH_BDB" OFF)
if(WITH_BDB)
find_package(BerkeleyDB 4.8 MODULE REQUIRED)
set(USE_BDB ON)
set(ENABLE_WALLET ON)
if(NOT BerkeleyDB_VERSION VERSION_EQUAL 4.8)
message(WARNING "Found Berkeley DB (BDB) other than 4.8.\n"
"BDB (legacy) wallets opened by this build will not be portable!"
)
if(WARN_INCOMPATIBLE_BDB)
message(WARNING "If this is intended, pass \"-DWARN_INCOMPATIBLE_BDB=OFF\".\n"
"Passing \"-DWITH_BDB=OFF\" will suppress this warning."
)
endif()
endif()
endif()
cmake_dependent_option(BUILD_WALLET_TOOL "Build bitcoin-wallet tool." ON "ENABLE_WALLET" OFF)

option(THREADLOCAL "Enable features that depend on the C++ thread_local keyword (currently just thread names in debug logs)." ON)
option(HARDENING "Attempt to harden the resulting executables." ON)
option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF)
option(WERROR "Treat compiler warnings as errors." OFF)

# TODO: These tri-state options will be removed and most features
# will become opt-in by default before merging into master.
include(TristateOption)
tristate_option(CCACHE "Use ccache for compiling." "if ccache is found." AUTO)

option(WITH_NATPMP "Enable NAT-PMP." OFF)
Expand Down
44 changes: 0 additions & 44 deletions cmake/optional.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,47 +49,3 @@ if(CCACHE)
endif()
mark_as_advanced(CCACHE_COMMAND)
endif()

if(ENABLE_WALLET)
if(WITH_SQLITE)
if(VCPKG_TARGET_TRIPLET)
# Use of the `unofficial::` namespace is a vcpkg package manager convention.
find_package(unofficial-sqlite3 CONFIG)
else()
find_package(SQLite3 3.7.17)
endif()
if(TARGET unofficial::sqlite3::sqlite3 OR TARGET SQLite::SQLite3)
set(WITH_SQLITE ON)
set(USE_SQLITE ON)
elseif(WITH_SQLITE STREQUAL "AUTO")
set(WITH_SQLITE OFF)
else()
message(FATAL_ERROR "SQLite requested, but not found.")
endif()
endif()

if(WITH_BDB)
find_package(BerkeleyDB 4.8 MODULE)
if(BerkeleyDB_FOUND)
set(WITH_BDB ON)
set(USE_BDB ON)
if(NOT BerkeleyDB_VERSION VERSION_EQUAL 4.8)
message(WARNING "Found Berkeley DB (BDB) other than 4.8.")
if(WARN_INCOMPATIBLE_BDB)
message(WARNING "BDB (legacy) wallets opened by this build would not be portable!\n"
"If this is intended, pass \"-DWARN_INCOMPATIBLE_BDB=OFF\".\n"
"Passing \"-DWITH_BDB=OFF\" will suppress this warning.\n")
else()
message(WARNING "BDB (legacy) wallets opened by this build will not be portable!")
endif()
endif()
else()
message(WARNING "Berkeley DB (BDB) required for legacy wallet support, but not found.\n"
"Passing \"-DWITH_BDB=OFF\" will suppress this warning.\n")
set(WITH_BDB OFF)
endif()
endif()
else()
set(WITH_SQLITE OFF)
set(WITH_BDB OFF)
endif()
18 changes: 12 additions & 6 deletions depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,22 @@ else()
set(WITH_ZMQ ON CACHE BOOL "")
endif()

if(NOT ENABLE_WALLET AND "@no_wallet@" STREQUAL "1")
set(ENABLE_WALLET OFF CACHE BOOL "Enable wallet.")
if("@no_wallet@")
set(ENABLE_WALLET OFF CACHE BOOL "")
else()
set(ENABLE_WALLET ON CACHE BOOL "")
endif()

if(NOT WITH_BDB AND "@no_bdb@" STREQUAL "1")
set(WITH_BDB OFF CACHE STRING "Enable Berkeley DB (BDB) wallet support.")
if("@no_wallet@" OR "@no_bdb@")
set(WITH_BDB OFF CACHE BOOL "")
else()
set(WITH_BDB ON CACHE BOOL "")
endif()

if(NOT WITH_SQLITE AND "@no_sqlite@" STREQUAL "1")
set(WITH_SQLITE OFF CACHE STRING "Enable SQLite wallet support.")
if("@no_wallet@" OR "@no_sqlite@")
set(WITH_SQLITE OFF CACHE BOOL "")
else()
set(WITH_SQLITE ON CACHE BOOL "")
endif()

if("@no_upnp@")
Expand Down

0 comments on commit f918ccb

Please sign in to comment.