Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Switch from tri-state options to boolean. Stage THREE #164

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just moved from before, but it is kind of a weird suggestion to suppress something by switching of an entire feature.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It came from

if test "$bdbpath" = "X"; then
use_bdb=no
AC_MSG_RESULT([no])
AC_MSG_WARN([libdb_cxx headers missing])
AC_MSG_WARN(AC_PACKAGE_NAME[ requires this library for BDB (legacy) wallet support])
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
elif test "$bdb48path" = "X"; then
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
AC_MSG_WARN([Found Berkeley DB other than 4.8])
AC_MSG_WARN([BDB (legacy) wallets opened by this build will not be portable!])
use_bdb=yes
],[
AC_MSG_WARN([Found Berkeley DB other than 4.8])
AC_MSG_WARN([BDB (legacy) wallets opened by this build would not be portable!])
AC_MSG_WARN([If this is intended, pass --with-incompatible-bdb])
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
use_bdb=no
])

Any suggestions to improve the behavior?

)
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
Loading