Skip to content

Commit

Permalink
Merge #173: cmake: Switch from tri-state options to boolean. Stage FI…
Browse files Browse the repository at this point in the history
…VE. The GUI

c46dd16 cmake [KILL 3-STATE]: Rename WITH_GUI to BUILD_GUI (Hennadii Stepanov)
d06252f cmake [KILL 3-STATE]: Make WITH_GUI binary option w/ default OFF (Hennadii Stepanov)

Pull request description:

  Replaces multi-value `WITH_GUI` with boolean `BUILD_GUI` as discussed during the recent call.

  The default value of the `BUILD_GUI` option is `OFF`.

  Documentation has been adjusted.

  While touching build docs, they were amended to use modern CMake invocations according to discussion in #167 (should be trivial to review though).

Top commit has no ACKs.

Tree-SHA512: ebe65f616e2044a6b09e8b1ff3685fd4f8fca6be2f2324db7495b56bbfdb03e6ab7d5a80d1a91ef903e11417590f9267cc2f80aa591379cb193ced36fbebbec0
  • Loading branch information
hebasto committed May 8, 2024
2 parents f17c406 + c46dd16 commit a6efc04
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ jobs:
- name: Generate build system
run: |
cmake -B build --preset ${{ matrix.conf.preset }} -DWERROR=ON
cmake -B build --preset ${{ matrix.conf.preset }} -DBUILD_GUI=ON -DWERROR=ON
- name: Save vcpkg binary cache
uses: actions/cache/save@v4
Expand Down
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module)
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_GUI "Build bitcoin-qt executable." OFF)
option(BUILD_CLI "Build bitcoin-cli executable." ON)
option(BUILD_TX "Build bitcoin-tx executable." ON)
option(BUILD_UTIL "Build bitcoin-util executable." ON)
Expand Down Expand Up @@ -143,8 +144,7 @@ endif()
cmake_dependent_option(WITH_EXTERNAL_SIGNER "Enable external signer support." ON "NOT WIN32" OFF)
set(ENABLE_EXTERNAL_SIGNER ${WITH_EXTERNAL_SIGNER})

include(cmake/optional_qt.cmake)
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "WITH_GUI" OFF)
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
if(WITH_QRENCODE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libqrencode REQUIRED IMPORTED_TARGET libqrencode)
Expand All @@ -160,7 +160,7 @@ if(MULTIPROCESS)
endif()

option(BUILD_TESTS "Build test_bitcoin executable." ON)
cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_TESTS" OFF)
cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_GUI;BUILD_TESTS" OFF)
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
option(BUILD_FUZZ_BINARY "Build fuzz binary." ON)
cmake_dependent_option(FUZZ "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF)
Expand Down Expand Up @@ -205,7 +205,7 @@ if(FUZZ)
set(BUILD_UTIL_CHAINSTATE OFF)
set(BUILD_KERNEL_LIB OFF)
set(BUILD_WALLET_TOOL OFF)
set(WITH_GUI OFF)
set(BUILD_GUI OFF)
set(WITH_EXTERNAL_SIGNER OFF)
set(WITH_NATPMP OFF)
set(WITH_MINIUPNPC OFF)
Expand Down Expand Up @@ -600,6 +600,7 @@ message("Configure summary")
message("=================")
message("Executables:")
message(" bitcoind ............................ ${BUILD_DAEMON}")
message(" bitcoin-qt .......................... ${BUILD_GUI}")
message(" bitcoin-cli ......................... ${BUILD_CLI}")
message(" bitcoin-tx .......................... ${BUILD_TX}")
message(" bitcoin-util ........................ ${BUILD_UTIL}")
Expand All @@ -610,16 +611,13 @@ message("Wallet support:")
message(" SQLite, descriptor wallets .......... ${WITH_SQLITE}")
message(" Berkeley DB, legacy wallets ......... ${WITH_BDB}")
message("Optional packages:")
message(" GUI ................................. ${WITH_GUI}")
if(WITH_GUI)
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
endif()
message(" external signer ..................... ${WITH_EXTERNAL_SIGNER}")
message(" multiprocess ........................ ${MULTIPROCESS}")
message(" NAT-PMP ............................. ${WITH_NATPMP}")
message(" UPnP ................................ ${WITH_MINIUPNPC}")
message(" ZeroMQ .............................. ${WITH_ZMQ}")
message(" USDT tracing ........................ ${WITH_USDT}")
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
message("Tests:")
message(" test_bitcoin ........................ ${BUILD_TESTS}")
message(" test_bitcoin-qt ..................... ${BUILD_GUI_TESTS}")
Expand Down
6 changes: 3 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"rhs": "Darwin"
},
"cacheVariables": {
"WITH_GUI": "Qt5",
"BUILD_GUI": "ON",
"WITH_EXTERNAL_SIGNER": "ON"
}
},
Expand All @@ -57,7 +57,7 @@
"toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows",
"WITH_GUI": "Qt5",
"BUILD_GUI": "ON",
"WITH_QRENCODE": "OFF",
"WITH_NATPMP": "OFF"
}
Expand All @@ -75,7 +75,7 @@
"toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"WITH_GUI": "Qt5",
"BUILD_GUI": "ON",
"WITH_QRENCODE": "OFF",
"WITH_NATPMP": "OFF"
}
Expand Down
62 changes: 62 additions & 0 deletions cmake/module/FindQt5.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright (c) 2024-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.

#[=======================================================================[
FindQt5
-------
Finds the Qt 5 headers and libraries.
This is a wrapper around find_package() command that:
- facilitates searching in various build environments
- prints a standard log message
#]=======================================================================]

set(_qt_homebrew_prefix)
if(CMAKE_HOST_APPLE)
find_program(HOMEBREW_EXECUTABLE brew)
if(HOMEBREW_EXECUTABLE)
execute_process(
COMMAND ${HOMEBREW_EXECUTABLE} --prefix qt@5
OUTPUT_VARIABLE _qt_homebrew_prefix
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()

# Save CMAKE_FIND_ROOT_PATH_MODE_LIBRARY state.
unset(_qt_find_root_path_mode_library_saved)
if(DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
set(_qt_find_root_path_mode_library_saved ${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY})
endif()

# The Qt config files internally use find_library() calls for all
# dependencies to ensure their availability. In turn, the find_library()
# inspects the well-known locations on the file system; therefore, it must
# be able to find platform-specific system libraries, for example:
# /usr/x86_64-w64-mingw32/lib/libm.a or /usr/arm-linux-gnueabihf/lib/libm.a.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)

find_package(Qt5 ${Qt5_FIND_VERSION}
COMPONENTS ${Qt5_FIND_COMPONENTS}
HINTS ${_qt_homebrew_prefix}
PATH_SUFFIXES Qt5 # Required on OpenBSD systems.
)
unset(_qt_homebrew_prefix)

# Restore CMAKE_FIND_ROOT_PATH_MODE_LIBRARY state.
if(DEFINED _qt_find_root_path_mode_library_saved)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ${_qt_find_root_path_mode_library_saved})
unset(_qt_find_root_path_mode_library_saved)
else()
unset(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Qt5
REQUIRED_VARS Qt5_DIR
VERSION_VAR Qt5_VERSION
)
51 changes: 0 additions & 51 deletions cmake/optional_qt.cmake

This file was deleted.

10 changes: 5 additions & 5 deletions depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ unset(pkg_config_path)
set(PKG_CONFIG_ARGN --static)


# Ensure that the docstrings in the following `set(... CACHE ...)`
# commands match those in the root CMakeLists.txt file.

if(NOT WITH_GUI AND "@no_qt@" STREQUAL "1")
set(WITH_GUI OFF CACHE STRING "Build GUI.")
# Set configuration options for the main build system.
if("@no_qt@")
set(BUILD_GUI OFF CACHE BOOL "")
else()
set(BUILD_GUI ON CACHE BOOL "")
endif()

if(NOT WITH_QRENCODE AND "@no_qr@" STREQUAL "1")
Expand Down
10 changes: 5 additions & 5 deletions doc/build-freebsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,23 @@ pkg install python3 databases/py-sqlite3
There are many ways to configure Bitcoin Core, here are a few common examples:

##### Descriptor Wallet and GUI:
This explicitly enables the GUI and disables legacy wallet support, assuming `sqlite` and `qt` are installed.
This disables legacy wallet support and enables the GUI, assuming `sqlite` and `qt` are installed.
```bash
cmake -B build -DWITH_BDB=OFF -DWITH_GUI=Qt5
cmake -B build -DWITH_BDB=OFF -DBUILD_GUI=ON
```

Run `cmake -B build -LH` to see the full list of available options.

##### Descriptor & Legacy Wallet. No GUI:
This enables support for both wallet types and disables the GUI, assuming
This enables support for both wallet types, assuming
`sqlite3` and `db4` are both installed.
```bash
cmake -B build -DWITH_GUI=OFF -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
cmake -B build -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
```

##### No Wallet or GUI
```bash
cmake -B build -DENABLE_WALLET=OFF -DWITH_GUI=OFF
cmake -B build -DENABLE_WALLET=OFF
```

### 2. Compile
Expand Down
8 changes: 4 additions & 4 deletions doc/build-openbsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ pkg_add install python # Select the newest version of the package.
There are many ways to configure Bitcoin Core, here are a few common examples:

##### Descriptor Wallet and GUI:
This enables the GUI and descriptor wallet support, assuming SQLite and Qt 5 are installed.
This enables descriptor wallet support and the GUI, assuming SQLite and Qt 5 are installed.

```bash
cmake -B build -DWITH_SQLITE=ON -DWITH_GUI=Qt5
cmake -B build -DWITH_SQLITE=ON -DBUILD_GUI=ON
```

Run `cmake -B build -LH` to see the full list of available options.

##### Descriptor & Legacy Wallet. No GUI:
This enables support for both wallet types and disables the GUI:
This enables support for both wallet types:

```bash
cmake -B build -DWITH_GUI=OFF -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
cmake -B build -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
```

### 2. Compile
Expand Down
9 changes: 4 additions & 5 deletions doc/build-osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,27 +190,26 @@ There are many ways to configure Bitcoin Core, here are a few common examples:

If `berkeley-db@4` is installed, then legacy wallet support will be built.
If `sqlite` is installed, then descriptor wallet support will also be built.
Additionally, this explicitly disables the GUI.

``` bash
cmake -B build -DWITH_GUI=OFF
cmake -B build
```

##### Wallet (only SQlite) and GUI Support:

This explicitly enables the GUI and disables legacy wallet support.
This enables the GUI and disables legacy wallet support.
If `qt` is not installed, this will throw an error.
If `sqlite` is installed then descriptor wallet functionality will be built.
If `sqlite` is not installed, then wallet functionality will be disabled.

``` bash
cmake -B build -DWITH_BDB=OFF -DWITH_GUI=Qt5
cmake -B build -DWITH_BDB=OFF -DBUILD_GUI=ON
```

##### No Wallet or GUI

``` bash
cmake -B build -DENABLE_WALLET=OFF -DWITH_GUI=OFF
cmake -B build -DENABLE_WALLET=OFF
```

##### Further Configuration
Expand Down
8 changes: 4 additions & 4 deletions doc/build-windows-msvc.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ CMake will put the resulting object files, libraries, and executables into a ded

In following istructions, the "Debug" configuration can be specified instead of the "Release" one.

### 4. Building with Dynamic Linking
### 4. Building with Dynamic Linking with GUI

```
cmake -B build --preset vs2022 # It might take a while if the vcpkg binary cache is unpopulated or invalidated.
cmake -B build --preset vs2022 -DBUILD_GUI=ON # It might take a while if the vcpkg binary cache is unpopulated or invalidated.
cmake --build build --config Release # Use "-j N" for N parallel jobs.
ctest --test-dir build --build-config Release # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available.
```

### 5. Building with Static Linking
### 5. Building with Static Linking without GUI

```
cmake -B build --preset vs2022-static # It might take a while if the vcpkg binary cache is unpopulated or invalidated.
Expand All @@ -72,7 +72,7 @@ cmake --install build --config Release # Optional.
One can skip vcpkg manifest default features to speedup the configuration step.
For example, the following invocation will skip all features except for "wallet" and "tests" and their dependencies:
```
cmake -B build --preset vs2022 -DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet;tests"
cmake -B build --preset vs2022 -DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet;tests" -DBUILD_GUI=OFF
```

Available features are listed in the [`vcpkg.json`](/vcpkg.json) file.
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ if(BUILD_UTIL)
endif()


if(WITH_GUI)
if(BUILD_GUI)
add_subdirectory(qt)
endif()

Expand Down
Loading

0 comments on commit a6efc04

Please sign in to comment.