Skip to content

Commit f918ccb

Browse files
committed
Merge #164: cmake: Switch from tri-state options to boolean. Stage THREE
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
2 parents 0be9840 + 2b4ad50 commit f918ccb

File tree

3 files changed

+47
-58
lines changed

3 files changed

+47
-58
lines changed

CMakeLists.txt

+35-8
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ set(CMAKE_CXX_EXTENSIONS OFF)
5757

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

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

6972
option(ENABLE_WALLET "Enable wallet." ON)
70-
# TODO: These tri-state options will be removed and most features
71-
# will become opt-in by default before merging into master.
72-
include(TristateOption)
73-
tristate_option(WITH_SQLITE "Enable SQLite wallet support." "if libsqlite3 is found." AUTO)
74-
tristate_option(WITH_BDB "Enable Berkeley DB (BDB) wallet support." "if libdb_cxx is found." AUTO)
75-
option(WARN_INCOMPATIBLE_BDB "Warn when using a Berkeley DB (BDB) version other than 4.8." ON)
76-
include(CMakeDependentOption)
73+
option(WITH_SQLITE "Enable SQLite wallet support." ${ENABLE_WALLET})
74+
if(WITH_SQLITE)
75+
if(VCPKG_TARGET_TRIPLET)
76+
# Use of the `unofficial::` namespace is a vcpkg package manager convention.
77+
find_package(unofficial-sqlite3 CONFIG REQUIRED)
78+
else()
79+
find_package(SQLite3 3.7.17 REQUIRED)
80+
endif()
81+
set(USE_SQLITE ON)
82+
set(ENABLE_WALLET ON)
83+
endif()
84+
option(WITH_BDB "Enable Berkeley DB (BDB) wallet support." OFF)
85+
cmake_dependent_option(WARN_INCOMPATIBLE_BDB "Warn when using a Berkeley DB (BDB) version other than 4.8." ON "WITH_BDB" OFF)
86+
if(WITH_BDB)
87+
find_package(BerkeleyDB 4.8 MODULE REQUIRED)
88+
set(USE_BDB ON)
89+
set(ENABLE_WALLET ON)
90+
if(NOT BerkeleyDB_VERSION VERSION_EQUAL 4.8)
91+
message(WARNING "Found Berkeley DB (BDB) other than 4.8.\n"
92+
"BDB (legacy) wallets opened by this build will not be portable!"
93+
)
94+
if(WARN_INCOMPATIBLE_BDB)
95+
message(WARNING "If this is intended, pass \"-DWARN_INCOMPATIBLE_BDB=OFF\".\n"
96+
"Passing \"-DWITH_BDB=OFF\" will suppress this warning."
97+
)
98+
endif()
99+
endif()
100+
endif()
77101
cmake_dependent_option(BUILD_WALLET_TOOL "Build bitcoin-wallet tool." ON "ENABLE_WALLET" OFF)
78102

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

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

86113
option(WITH_NATPMP "Enable NAT-PMP." OFF)

cmake/optional.cmake

-44
Original file line numberDiff line numberDiff line change
@@ -49,47 +49,3 @@ if(CCACHE)
4949
endif()
5050
mark_as_advanced(CCACHE_COMMAND)
5151
endif()
52-
53-
if(ENABLE_WALLET)
54-
if(WITH_SQLITE)
55-
if(VCPKG_TARGET_TRIPLET)
56-
# Use of the `unofficial::` namespace is a vcpkg package manager convention.
57-
find_package(unofficial-sqlite3 CONFIG)
58-
else()
59-
find_package(SQLite3 3.7.17)
60-
endif()
61-
if(TARGET unofficial::sqlite3::sqlite3 OR TARGET SQLite::SQLite3)
62-
set(WITH_SQLITE ON)
63-
set(USE_SQLITE ON)
64-
elseif(WITH_SQLITE STREQUAL "AUTO")
65-
set(WITH_SQLITE OFF)
66-
else()
67-
message(FATAL_ERROR "SQLite requested, but not found.")
68-
endif()
69-
endif()
70-
71-
if(WITH_BDB)
72-
find_package(BerkeleyDB 4.8 MODULE)
73-
if(BerkeleyDB_FOUND)
74-
set(WITH_BDB ON)
75-
set(USE_BDB ON)
76-
if(NOT BerkeleyDB_VERSION VERSION_EQUAL 4.8)
77-
message(WARNING "Found Berkeley DB (BDB) other than 4.8.")
78-
if(WARN_INCOMPATIBLE_BDB)
79-
message(WARNING "BDB (legacy) wallets opened by this build would not be portable!\n"
80-
"If this is intended, pass \"-DWARN_INCOMPATIBLE_BDB=OFF\".\n"
81-
"Passing \"-DWITH_BDB=OFF\" will suppress this warning.\n")
82-
else()
83-
message(WARNING "BDB (legacy) wallets opened by this build will not be portable!")
84-
endif()
85-
endif()
86-
else()
87-
message(WARNING "Berkeley DB (BDB) required for legacy wallet support, but not found.\n"
88-
"Passing \"-DWITH_BDB=OFF\" will suppress this warning.\n")
89-
set(WITH_BDB OFF)
90-
endif()
91-
endif()
92-
else()
93-
set(WITH_SQLITE OFF)
94-
set(WITH_BDB OFF)
95-
endif()

depends/toolchain.cmake.in

+12-6
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,22 @@ else()
134134
set(WITH_ZMQ ON CACHE BOOL "")
135135
endif()
136136

137-
if(NOT ENABLE_WALLET AND "@no_wallet@" STREQUAL "1")
138-
set(ENABLE_WALLET OFF CACHE BOOL "Enable wallet.")
137+
if("@no_wallet@")
138+
set(ENABLE_WALLET OFF CACHE BOOL "")
139+
else()
140+
set(ENABLE_WALLET ON CACHE BOOL "")
139141
endif()
140142

141-
if(NOT WITH_BDB AND "@no_bdb@" STREQUAL "1")
142-
set(WITH_BDB OFF CACHE STRING "Enable Berkeley DB (BDB) wallet support.")
143+
if("@no_wallet@" OR "@no_bdb@")
144+
set(WITH_BDB OFF CACHE BOOL "")
145+
else()
146+
set(WITH_BDB ON CACHE BOOL "")
143147
endif()
144148

145-
if(NOT WITH_SQLITE AND "@no_sqlite@" STREQUAL "1")
146-
set(WITH_SQLITE OFF CACHE STRING "Enable SQLite wallet support.")
149+
if("@no_wallet@" OR "@no_sqlite@")
150+
set(WITH_SQLITE OFF CACHE BOOL "")
151+
else()
152+
set(WITH_SQLITE ON CACHE BOOL "")
147153
endif()
148154

149155
if("@no_upnp@")

0 commit comments

Comments
 (0)