Skip to content

Commit a6efc04

Browse files
committed
Merge #173: cmake: Switch from tri-state options to boolean. Stage FIVE. 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
2 parents f17c406 + c46dd16 commit a6efc04

12 files changed

+116
-114
lines changed

.github/workflows/cmake.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ jobs:
464464
465465
- name: Generate build system
466466
run: |
467-
cmake -B build --preset ${{ matrix.conf.preset }} -DWERROR=ON
467+
cmake -B build --preset ${{ matrix.conf.preset }} -DBUILD_GUI=ON -DWERROR=ON
468468
469469
- name: Save vcpkg binary cache
470470
uses: actions/cache/save@v4

CMakeLists.txt

+6-8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module)
6363
include(CMakeDependentOption)
6464
# When adding a new option, end the <help_text> with a full stop for consistency.
6565
option(BUILD_DAEMON "Build bitcoind executable." ON)
66+
option(BUILD_GUI "Build bitcoin-qt executable." OFF)
6667
option(BUILD_CLI "Build bitcoin-cli executable." ON)
6768
option(BUILD_TX "Build bitcoin-tx executable." ON)
6869
option(BUILD_UTIL "Build bitcoin-util executable." ON)
@@ -143,8 +144,7 @@ endif()
143144
cmake_dependent_option(WITH_EXTERNAL_SIGNER "Enable external signer support." ON "NOT WIN32" OFF)
144145
set(ENABLE_EXTERNAL_SIGNER ${WITH_EXTERNAL_SIGNER})
145146

146-
include(cmake/optional_qt.cmake)
147-
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "WITH_GUI" OFF)
147+
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
148148
if(WITH_QRENCODE)
149149
find_package(PkgConfig REQUIRED)
150150
pkg_check_modules(libqrencode REQUIRED IMPORTED_TARGET libqrencode)
@@ -160,7 +160,7 @@ if(MULTIPROCESS)
160160
endif()
161161

162162
option(BUILD_TESTS "Build test_bitcoin executable." ON)
163-
cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_TESTS" OFF)
163+
cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_GUI;BUILD_TESTS" OFF)
164164
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
165165
option(BUILD_FUZZ_BINARY "Build fuzz binary." ON)
166166
cmake_dependent_option(FUZZ "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF)
@@ -205,7 +205,7 @@ if(FUZZ)
205205
set(BUILD_UTIL_CHAINSTATE OFF)
206206
set(BUILD_KERNEL_LIB OFF)
207207
set(BUILD_WALLET_TOOL OFF)
208-
set(WITH_GUI OFF)
208+
set(BUILD_GUI OFF)
209209
set(WITH_EXTERNAL_SIGNER OFF)
210210
set(WITH_NATPMP OFF)
211211
set(WITH_MINIUPNPC OFF)
@@ -600,6 +600,7 @@ message("Configure summary")
600600
message("=================")
601601
message("Executables:")
602602
message(" bitcoind ............................ ${BUILD_DAEMON}")
603+
message(" bitcoin-qt .......................... ${BUILD_GUI}")
603604
message(" bitcoin-cli ......................... ${BUILD_CLI}")
604605
message(" bitcoin-tx .......................... ${BUILD_TX}")
605606
message(" bitcoin-util ........................ ${BUILD_UTIL}")
@@ -610,16 +611,13 @@ message("Wallet support:")
610611
message(" SQLite, descriptor wallets .......... ${WITH_SQLITE}")
611612
message(" Berkeley DB, legacy wallets ......... ${WITH_BDB}")
612613
message("Optional packages:")
613-
message(" GUI ................................. ${WITH_GUI}")
614-
if(WITH_GUI)
615-
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
616-
endif()
617614
message(" external signer ..................... ${WITH_EXTERNAL_SIGNER}")
618615
message(" multiprocess ........................ ${MULTIPROCESS}")
619616
message(" NAT-PMP ............................. ${WITH_NATPMP}")
620617
message(" UPnP ................................ ${WITH_MINIUPNPC}")
621618
message(" ZeroMQ .............................. ${WITH_ZMQ}")
622619
message(" USDT tracing ........................ ${WITH_USDT}")
620+
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
623621
message("Tests:")
624622
message(" test_bitcoin ........................ ${BUILD_TESTS}")
625623
message(" test_bitcoin-qt ..................... ${BUILD_GUI_TESTS}")

CMakePresets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"rhs": "Darwin"
4141
},
4242
"cacheVariables": {
43-
"WITH_GUI": "Qt5",
43+
"BUILD_GUI": "ON",
4444
"WITH_EXTERNAL_SIGNER": "ON"
4545
}
4646
},
@@ -57,7 +57,7 @@
5757
"toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake",
5858
"cacheVariables": {
5959
"VCPKG_TARGET_TRIPLET": "x64-windows",
60-
"WITH_GUI": "Qt5",
60+
"BUILD_GUI": "ON",
6161
"WITH_QRENCODE": "OFF",
6262
"WITH_NATPMP": "OFF"
6363
}
@@ -75,7 +75,7 @@
7575
"toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake",
7676
"cacheVariables": {
7777
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
78-
"WITH_GUI": "Qt5",
78+
"BUILD_GUI": "ON",
7979
"WITH_QRENCODE": "OFF",
8080
"WITH_NATPMP": "OFF"
8181
}

cmake/module/FindQt5.cmake

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright (c) 2024-present The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or https://opensource.org/license/mit/.
4+
5+
#[=======================================================================[
6+
FindQt5
7+
-------
8+
9+
Finds the Qt 5 headers and libraries.
10+
11+
This is a wrapper around find_package() command that:
12+
- facilitates searching in various build environments
13+
- prints a standard log message
14+
15+
#]=======================================================================]
16+
17+
set(_qt_homebrew_prefix)
18+
if(CMAKE_HOST_APPLE)
19+
find_program(HOMEBREW_EXECUTABLE brew)
20+
if(HOMEBREW_EXECUTABLE)
21+
execute_process(
22+
COMMAND ${HOMEBREW_EXECUTABLE} --prefix qt@5
23+
OUTPUT_VARIABLE _qt_homebrew_prefix
24+
ERROR_QUIET
25+
OUTPUT_STRIP_TRAILING_WHITESPACE
26+
)
27+
endif()
28+
endif()
29+
30+
# Save CMAKE_FIND_ROOT_PATH_MODE_LIBRARY state.
31+
unset(_qt_find_root_path_mode_library_saved)
32+
if(DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
33+
set(_qt_find_root_path_mode_library_saved ${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY})
34+
endif()
35+
36+
# The Qt config files internally use find_library() calls for all
37+
# dependencies to ensure their availability. In turn, the find_library()
38+
# inspects the well-known locations on the file system; therefore, it must
39+
# be able to find platform-specific system libraries, for example:
40+
# /usr/x86_64-w64-mingw32/lib/libm.a or /usr/arm-linux-gnueabihf/lib/libm.a.
41+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
42+
43+
find_package(Qt5 ${Qt5_FIND_VERSION}
44+
COMPONENTS ${Qt5_FIND_COMPONENTS}
45+
HINTS ${_qt_homebrew_prefix}
46+
PATH_SUFFIXES Qt5 # Required on OpenBSD systems.
47+
)
48+
unset(_qt_homebrew_prefix)
49+
50+
# Restore CMAKE_FIND_ROOT_PATH_MODE_LIBRARY state.
51+
if(DEFINED _qt_find_root_path_mode_library_saved)
52+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ${_qt_find_root_path_mode_library_saved})
53+
unset(_qt_find_root_path_mode_library_saved)
54+
else()
55+
unset(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
56+
endif()
57+
58+
include(FindPackageHandleStandardArgs)
59+
find_package_handle_standard_args(Qt5
60+
REQUIRED_VARS Qt5_DIR
61+
VERSION_VAR Qt5_VERSION
62+
)

cmake/optional_qt.cmake

-51
This file was deleted.

depends/toolchain.cmake.in

+5-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ unset(pkg_config_path)
117117
set(PKG_CONFIG_ARGN --static)
118118

119119

120-
# Ensure that the docstrings in the following `set(... CACHE ...)`
121-
# commands match those in the root CMakeLists.txt file.
122-
123-
if(NOT WITH_GUI AND "@no_qt@" STREQUAL "1")
124-
set(WITH_GUI OFF CACHE STRING "Build GUI.")
120+
# Set configuration options for the main build system.
121+
if("@no_qt@")
122+
set(BUILD_GUI OFF CACHE BOOL "")
123+
else()
124+
set(BUILD_GUI ON CACHE BOOL "")
125125
endif()
126126

127127
if(NOT WITH_QRENCODE AND "@no_qr@" STREQUAL "1")

doc/build-freebsd.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,23 @@ pkg install python3 databases/py-sqlite3
101101
There are many ways to configure Bitcoin Core, here are a few common examples:
102102

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

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

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

118118
##### No Wallet or GUI
119119
```bash
120-
cmake -B build -DENABLE_WALLET=OFF -DWITH_GUI=OFF
120+
cmake -B build -DENABLE_WALLET=OFF
121121
```
122122

123123
### 2. Compile

doc/build-openbsd.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ pkg_add install python # Select the newest version of the package.
7979
There are many ways to configure Bitcoin Core, here are a few common examples:
8080

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

8484
```bash
85-
cmake -B build -DWITH_SQLITE=ON -DWITH_GUI=Qt5
85+
cmake -B build -DWITH_SQLITE=ON -DBUILD_GUI=ON
8686
```
8787

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

9090
##### Descriptor & Legacy Wallet. No GUI:
91-
This enables support for both wallet types and disables the GUI:
91+
This enables support for both wallet types:
9292

9393
```bash
94-
cmake -B build -DWITH_GUI=OFF -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
94+
cmake -B build -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
9595
```
9696

9797
### 2. Compile

doc/build-osx.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -190,27 +190,26 @@ There are many ways to configure Bitcoin Core, here are a few common examples:
190190

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

195194
``` bash
196-
cmake -B build -DWITH_GUI=OFF
195+
cmake -B build
197196
```
198197

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

201-
This explicitly enables the GUI and disables legacy wallet support.
200+
This enables the GUI and disables legacy wallet support.
202201
If `qt` is not installed, this will throw an error.
203202
If `sqlite` is installed then descriptor wallet functionality will be built.
204203
If `sqlite` is not installed, then wallet functionality will be disabled.
205204

206205
``` bash
207-
cmake -B build -DWITH_BDB=OFF -DWITH_GUI=Qt5
206+
cmake -B build -DWITH_BDB=OFF -DBUILD_GUI=ON
208207
```
209208

210209
##### No Wallet or GUI
211210

212211
``` bash
213-
cmake -B build -DENABLE_WALLET=OFF -DWITH_GUI=OFF
212+
cmake -B build -DENABLE_WALLET=OFF
214213
```
215214

216215
##### Further Configuration

doc/build-windows-msvc.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ CMake will put the resulting object files, libraries, and executables into a ded
4848

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

51-
### 4. Building with Dynamic Linking
51+
### 4. Building with Dynamic Linking with GUI
5252

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

59-
### 5. Building with Static Linking
59+
### 5. Building with Static Linking without GUI
6060

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

7878
Available features are listed in the [`vcpkg.json`](/vcpkg.json) file.

src/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ if(BUILD_UTIL)
343343
endif()
344344

345345

346-
if(WITH_GUI)
346+
if(BUILD_GUI)
347347
add_subdirectory(qt)
348348
endif()
349349

0 commit comments

Comments
 (0)