Skip to content

Commit 6ce50fd

Browse files
hebastol0rincpablomartin4btc
committed
doc: Update for CMake-based build system
Co-authored-by: Lőrinc <[email protected]> Co-authored-by: pablomartin4btc <[email protected]>
1 parent 9730288 commit 6ce50fd

18 files changed

+349
-274
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ lots of money.
4848

4949
Developers are strongly encouraged to write [unit tests](src/test/README.md) for new code, and to
5050
submit new unit tests for old code. Unit tests can be compiled and run
51-
(assuming they weren't disabled in configure) with: `make check`. Further details on running
51+
(assuming they weren't disabled during the generation of the build system) with: `ctest`. Further details on running
5252
and extending unit tests can be found in [/src/test/README.md](/src/test/README.md).
5353

5454
There are also [regression and integration tests](/test), written

contrib/guix/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ details.
261261

262262
- `guix` build commands as in `guix shell --cores="$JOBS"`
263263
- `make` as in `make --jobs="$JOBS"`
264+
- `cmake` as in `cmake --build build -j "$JOBS"`
264265
- `xargs` as in `xargs -P"$JOBS"`
265266

266267
See [here](#controlling-the-number-of-threads-used-by-guix-build-commands) for

depends/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@ For example:
1212

1313
make HOST=x86_64-w64-mingw32 -j4
1414

15-
**Bitcoin Core's `configure` script by default will ignore the depends output.** In
15+
**When configuring Bitcoin Core, CMake by default will ignore the depends output.** In
1616
order for it to pick up libraries, tools, and settings from the depends build,
17-
you must set the `CONFIG_SITE` environment variable to point to a `config.site` settings file.
18-
Make sure that `CONFIG_SITE` is an absolute path.
19-
In the above example, a file named `depends/x86_64-w64-mingw32/share/config.site` will be
20-
created. To use it during compilation:
17+
you must specify the toolchain file.
18+
In the above example, a file named `depends/x86_64-w64-mingw32/toolchain.cmake` will be
19+
created. To use it during configuring Bitcoin Core:
2120

22-
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure
23-
24-
The default install prefix when using `config.site` is `--prefix=depends/<host-platform-triplet>`,
25-
so depends build outputs will be installed in that location.
21+
cmake -B build --toolchain depends/x86_64-w64-mingw32/toolchain.cmake
2622

2723
Common `host-platform-triplet`s for cross compilation are:
2824

@@ -90,9 +86,13 @@ For linux S390X cross compilation:
9086

9187
pkg install bash
9288

89+
### Install the required dependencies: NetBSD
90+
91+
pkgin install bash gmake
92+
9393
### Install the required dependencies: OpenBSD
9494

95-
pkg_add bash gtar
95+
pkg_add bash gmake gtar
9696

9797
### Dependency Options
9898

@@ -125,8 +125,8 @@ The following can be set when running make: `make FOO=bar`
125125
- `LTO`: Enable options needed for LTO. Does not add `-flto` related options to *FLAGS.
126126
- `NO_HARDEN=1`: Don't use hardening options when building packages
127127

128-
If some packages are not built, for example `make NO_WALLET=1`, the appropriate
129-
options will be passed to bitcoin's configure. In this case, `--disable-wallet`.
128+
If some packages are not built, for example `make NO_WALLET=1`, the appropriate CMake cache
129+
variables will be set when generating the Bitcoin Core buildsystem. In this case, `-DENABLE_WALLET=OFF`.
130130

131131
### Additional targets
132132

doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The following are developer notes on how to build Bitcoin Core on your native pl
4141
- [Dependencies](dependencies.md)
4242
- [macOS Build Notes](build-osx.md)
4343
- [Unix Build Notes](build-unix.md)
44-
- [Windows Build Notes](build-windows.md)
44+
- [Windows Build Notes](build-windows-msvc.md)
4545
- [FreeBSD Build Notes](build-freebsd.md)
4646
- [OpenBSD Build Notes](build-openbsd.md)
4747
- [NetBSD Build Notes](build-netbsd.md)

doc/benchmarking.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ thread queue, wallet balance.
88
Running
99
---------------------
1010

11-
For benchmarking, you only need to compile `bitcoin_bench`. The bench runner
12-
warns if you configure with `--enable-debug`, but consider if building without
11+
For benchmarking, you only need to compile `bench_bitcoin`. The bench runner
12+
warns if you configure with `-DCMAKE_BUILD_TYPE=Debug`, but consider if building without
1313
it will impact the benchmark(s) you are interested in by unlatching log printers
1414
and lock analysis.
1515

16-
make -C src bitcoin_bench
16+
cmake -B build -DBUILD_BENCH=ON
17+
cmake --build build -t bench_bitcoin
1718

1819
After compiling bitcoin-core, the benchmarks can be run with:
1920

20-
src/bench/bench_bitcoin
21+
build/src/bench/bench_bitcoin
2122

2223
The output will look similar to:
2324
```
@@ -39,7 +40,7 @@ The output will look similar to:
3940
Help
4041
---------------------
4142

42-
src/bench/bench_bitcoin -?
43+
build/src/bench/bench_bitcoin -?
4344

4445
To print the various options, like listing the benchmarks without running them
4546
or using a regex filter to only run certain benchmarks.

doc/build-freebsd.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ This guide describes how to build bitcoind, command-line utilities, and GUI on F
1010
Run the following as root to install the base dependencies for building.
1111

1212
```bash
13-
pkg install autoconf automake boost-libs git gmake libevent libtool pkgconf
14-
13+
pkg install boost-libs cmake git libevent pkgconf
1514
```
1615

1716
See [dependencies.md](dependencies.md) for a complete overview.
1817

1918
### 2. Clone Bitcoin Repo
2019
Now that `git` and all the required dependencies are installed, let's clone the Bitcoin Core repository to a directory. All build scripts and commands will run from this directory.
21-
``` bash
20+
```bash
2221
git clone https://github.com/bitcoin/bitcoin.git
2322
```
2423

@@ -31,7 +30,7 @@ It is not necessary to build wallet functionality to run either `bitcoind` or `b
3130

3231
`sqlite3` is required to support [descriptor wallets](descriptors.md).
3332
Skip if you don't intend to use descriptor wallets.
34-
``` bash
33+
```bash
3534
pkg install sqlite3
3635
```
3736

@@ -41,7 +40,8 @@ BerkeleyDB is only required if legacy wallet support is required.
4140
It is required to use Berkeley DB 4.8. You **cannot** use the BerkeleyDB library
4241
from ports. However, you can build DB 4.8 yourself [using depends](/depends).
4342

44-
```
43+
```bash
44+
pkg install gmake
4545
gmake -C depends NO_BOOST=1 NO_LIBEVENT=1 NO_QT=1 NO_SQLITE=1 NO_NATPMP=1 NO_UPNP=1 NO_ZMQ=1 NO_USDT=1
4646
```
4747

@@ -64,17 +64,23 @@ sh/bash: export BDB_PREFIX=[path displayed above]
6464
#### GUI Dependencies
6565
###### Qt5
6666

67-
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install the necessary parts of Qt. Skip if you don't intend to use the GUI.
67+
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
68+
the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
69+
6870
```bash
6971
pkg install qt5-buildtools qt5-core qt5-gui qt5-linguisttools qt5-testlib qt5-widgets
7072
```
7173

7274
###### libqrencode
7375

74-
The GUI can encode addresses in a QR Code. To build in QR support for the GUI, install `libqrencode`. Skip if not using the GUI or don't want QR code functionality.
76+
The GUI will be able to encode addresses in QR codes unless this feature is explicitly disabled. To install libqrencode, run:
77+
7578
```bash
7679
pkg install libqrencode
7780
```
81+
82+
Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI.
83+
7884
---
7985

8086
#### Notifications
@@ -101,33 +107,28 @@ pkg install python3 databases/py-sqlite3
101107
There are many ways to configure Bitcoin Core, here are a few common examples:
102108

103109
##### Descriptor Wallet and GUI:
104-
This explicitly enables the GUI and disables legacy wallet support, assuming `sqlite` and `qt` are installed.
110+
This disables legacy wallet support and enables the GUI, assuming `sqlite` and `qt` are installed.
105111
```bash
106-
./autogen.sh
107-
./configure --without-bdb --with-gui=yes MAKE=gmake
112+
cmake -B build -DWITH_BDB=OFF -DBUILD_GUI=ON
108113
```
109114

115+
Run `cmake -B build -LH` to see the full list of available options.
116+
110117
##### Descriptor & Legacy Wallet. No GUI:
111-
This enables support for both wallet types and disables the GUI, assuming
118+
This enables support for both wallet types, assuming
112119
`sqlite3` and `db4` are both installed.
113120
```bash
114-
./autogen.sh
115-
./configure --with-gui=no \
116-
BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" \
117-
BDB_CFLAGS="-I${BDB_PREFIX}/include" \
118-
MAKE=gmake
121+
cmake -B build -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
119122
```
120123

121124
##### No Wallet or GUI
122-
``` bash
123-
./autogen.sh
124-
./configure --without-wallet --with-gui=no MAKE=gmake
125+
```bash
126+
cmake -B build -DENABLE_WALLET=OFF
125127
```
126128

127129
### 2. Compile
128-
**Important**: Use `gmake` (the non-GNU `make` will exit with an error).
129130

130131
```bash
131-
gmake # use "-j N" for N parallel jobs
132-
gmake check # Run tests if Python 3 is available
132+
cmake --build build # Use "-j N" for N parallel jobs.
133+
ctest --test-dir build # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available.
133134
```

doc/build-netbsd.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ Install the required dependencies the usual way you [install software on NetBSD]
1212
The example commands below use `pkgin`.
1313

1414
```bash
15-
pkgin install autoconf automake libtool pkg-config git gmake boost-headers libevent
16-
15+
pkgin install git cmake pkg-config boost-headers libevent
1716
```
1817

1918
NetBSD currently ships with an older version of `gcc` than is needed to build. You should upgrade your `gcc` and then pass this new version to the configure script.
@@ -25,10 +24,10 @@ pkgin install gcc12
2524

2625
Then, when configuring, pass the following:
2726
```bash
28-
./configure
27+
cmake -B build
2928
...
30-
CC="/usr/pkg/gcc12/bin/gcc" \
31-
CXX="/usr/pkg/gcc12/bin/g++" \
29+
-DCMAKE_C_COMPILER="/usr/pkg/gcc12/bin/gcc" \
30+
-DCMAKE_CXX_COMPILER="/usr/pkg/gcc12/bin/g++" \
3231
...
3332
```
3433

@@ -65,19 +64,26 @@ pkgin install db4
6564
```
6665

6766
#### GUI Dependencies
67+
###### Qt5
6868

69-
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, Qt 5 is required.
69+
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
70+
the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
7071

7172
```bash
7273
pkgin install qt5-qtbase qt5-qttools
7374
```
7475

75-
The GUI can encode addresses in a QR Code. To build in QR support for the GUI, install `qrencode`.
76+
###### libqrencode
77+
78+
The GUI will be able to encode addresses in QR codes unless this feature is explicitly disabled. To install libqrencode, run:
7679

7780
```bash
7881
pkgin install qrencode
7982
```
8083

84+
Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI.
85+
86+
8187
#### Test Suite Dependencies
8288

8389
There is an included test suite that is useful for testing code changes when developing.
@@ -89,28 +95,22 @@ pkgin install python39
8995

9096
### Building Bitcoin Core
9197

92-
**Note**: Use `gmake` (the non-GNU `make` will exit with an error).
93-
94-
9598
### 1. Configuration
9699

97100
There are many ways to configure Bitcoin Core. Here is an example that
98101
explicitly disables the wallet and GUI:
99102

100103
```bash
101-
./autogen.sh
102-
./configure --without-wallet --with-gui=no \
103-
CPPFLAGS="-I/usr/pkg/include" \
104-
MAKE=gmake
104+
cmake -B build -DENABLE_WALLET=OFF -DBUILD_GUI=OFF
105105
```
106106

107-
For a full list of configuration options, see the output of `./configure --help`
107+
Run `cmake -B build -LH` to see the full list of available options.
108108

109109
### 2. Compile
110110

111111
Build and run the tests:
112112

113113
```bash
114-
gmake # use "-j N" here for N parallel jobs
115-
gmake check # Run tests if Python 3 is available
114+
cmake --build build # Use "-j N" for N parallel jobs.
115+
ctest --test-dir build # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available.
116116
```

0 commit comments

Comments
 (0)