Skip to content

Commit

Permalink
doc: Update for CMake-based build system
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Jul 16, 2024
1 parent b9ea4de commit 2b7c0f4
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 171 deletions.
2 changes: 1 addition & 1 deletion build_msvc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To build Bitcoin Core from the command-line, it is sufficient to only install th

The "Desktop development with C++" workload must be installed as well.

Building with Visual Studio is an alternative to the Linux based [cross-compiler build](../doc/build-windows.md).
Building with Visual Studio is an alternative to the Linux based [cross-compiler build](../doc/build-windows-mingw.md).


Prerequisites
Expand Down
22 changes: 11 additions & 11 deletions depends/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ For example:

make HOST=x86_64-w64-mingw32 -j4

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

CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure

The default install prefix when using `config.site` is `--prefix=depends/<host-platform-triplet>`,
so depends build outputs will be installed in that location.
cmake -B build --toolchain depends/x86_64-w64-mingw32/toolchain.cmake

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

Expand Down Expand Up @@ -58,7 +54,7 @@ For more information, see [SDK Extraction](../contrib/macdeploy/README.md#sdk-ex

#### For Win64 cross compilation

- see [build-windows.md](../doc/build-windows.md#cross-compilation-for-ubuntu-and-windows-subsystem-for-linux)
- see [build-windows-mingw.md](../doc/build-windows-mingw.md#cross-compilation-for-ubuntu-and-windows-subsystem-for-linux)

#### For linux (including i386, ARM) cross compilation

Expand Down Expand Up @@ -90,9 +86,13 @@ For linux S390X cross compilation:

pkg install bash

### Install the required dependencies: NetBSD

pkgin install bash gmake

### Install the required dependencies: OpenBSD

pkg_add bash gtar
pkg_add bash gmake gtar

### Dependency Options

Expand Down
2 changes: 1 addition & 1 deletion depends/funcs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ $(1)_autoconf += LDFLAGS="$$($(1)_ldflags)"
endif

# We hardcode the library install path to "lib" to match the PKG_CONFIG_PATH
# setting in depends/config.site.in, which also hardcodes "lib".
# setting in depends/toolchain.cmake.in, which also hardcodes "lib".
# Without this setting, CMake by default would use the OS library
# directory, which might be "lib64" or something else, not "lib", on multiarch systems.
$(1)_cmake=env CC="$$($(1)_cc)" \
Expand Down
2 changes: 1 addition & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following are developer notes on how to build Bitcoin Core on your native pl
- [Dependencies](dependencies.md)
- [macOS Build Notes](build-osx.md)
- [Unix Build Notes](build-unix.md)
- [Windows Build Notes](build-windows.md)
- [Windows Build Notes](build-windows-msvc.md)
- [FreeBSD Build Notes](build-freebsd.md)
- [OpenBSD Build Notes](build-openbsd.md)
- [NetBSD Build Notes](build-netbsd.md)
Expand Down
35 changes: 15 additions & 20 deletions doc/build-freebsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ This guide describes how to build bitcoind, command-line utilities, and GUI on F
Run the following as root to install the base dependencies for building.

```bash
pkg install autoconf automake boost-libs git gmake libevent libtool pkgconf

pkg install boost-libs cmake git libevent pkgconf
```

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

### 2. Clone Bitcoin Repo
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.
``` bash
```bash
git clone https://github.com/bitcoin/bitcoin.git
```

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

`sqlite3` is required to support [descriptor wallets](descriptors.md).
Skip if you don't intend to use descriptor wallets.
``` bash
```bash
pkg install sqlite3
```

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

```
```bash
pkg install gmake
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
```

Expand Down Expand Up @@ -101,33 +101,28 @@ 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
./autogen.sh
./configure --without-bdb --with-gui=yes MAKE=gmake
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
./autogen.sh
./configure --with-gui=no \
BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" \
BDB_CFLAGS="-I${BDB_PREFIX}/include" \
MAKE=gmake
cmake -B build -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
```

##### No Wallet or GUI
``` bash
./autogen.sh
./configure --without-wallet --with-gui=no MAKE=gmake
```bash
cmake -B build -DENABLE_WALLET=OFF
```

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

```bash
gmake # use "-j N" for N parallel jobs
gmake check # Run tests if Python 3 is available
cmake --build build # Use "-j N" for N parallel jobs.
ctest --test-dir build # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available.
```
23 changes: 8 additions & 15 deletions doc/build-netbsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Install the required dependencies the usual way you [install software on NetBSD]
The example commands below use `pkgin`.

```bash
pkgin install autoconf automake libtool pkg-config git gmake boost-headers libevent

pkgin install git cmake pkg-config boost-headers libevent
```

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.
Expand All @@ -25,10 +24,10 @@ pkgin install gcc12

Then, when configuring, pass the following:
```bash
./configure
cmake -B build
...
CC="/usr/pkg/gcc12/bin/gcc" \
CXX="/usr/pkg/gcc12/bin/g++" \
-DCMAKE_C_COMPILER="/usr/pkg/gcc12/bin/gcc" \
-DCMAKE_CXX_COMPILER="/usr/pkg/gcc12/bin/g++" \
...
```

Expand Down Expand Up @@ -89,28 +88,22 @@ pkgin install python39

### Building Bitcoin Core

**Note**: Use `gmake` (the non-GNU `make` will exit with an error).


### 1. Configuration

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

```bash
./autogen.sh
./configure --without-wallet --with-gui=no \
CPPFLAGS="-I/usr/pkg/include" \
MAKE=gmake
cmake -B build -DENABLE_WALLET=OFF -DBUILD_GUI=OFF
```

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

### 2. Compile

Build and run the tests:

```bash
gmake # use "-j N" here for N parallel jobs
gmake check # Run tests if Python 3 is available
cmake --build build # Use "-j N" for N parallel jobs.
ctest --test-dir build # Use "-j N" for N parallel tests. Some tests are disabled if Python 3 is not available.
```
44 changes: 18 additions & 26 deletions doc/build-openbsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ This guide describes how to build bitcoind, command-line utilities, and GUI on O
Run the following as root to install the base dependencies for building.

```bash
pkg_add bash git gmake libevent libtool boost
# Select the newest version of the following packages:
pkg_add autoconf automake python
pkg_add git cmake boost libevent
```

See [dependencies.md](dependencies.md) for a complete overview.
Expand All @@ -31,7 +29,7 @@ It is not necessary to build wallet functionality to run either `bitcoind` or `b

###### Descriptor Wallet Support

`sqlite3` is required to support [descriptor wallets](descriptors.md).
SQLite is required to support [descriptor wallets](descriptors.md).

``` bash
pkg_add sqlite3
Expand All @@ -48,13 +46,13 @@ Refer to [depends/README.md](/depends/README.md) for detailed instructions.
```bash
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
...
to: /path/to/bitcoin/depends/x86_64-unknown-openbsd
to: /path/to/bitcoin/depends/*-unknown-openbsd*
```

Then set `BDB_PREFIX`:

```bash
export BDB_PREFIX="/path/to/bitcoin/depends/x86_64-unknown-openbsd"
export BDB_PREFIX="[path displayed above]"
```

#### GUI Dependencies
Expand All @@ -66,47 +64,41 @@ Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compi
pkg_add qtbase qttools
```

## Building Bitcoin Core

**Important**: Use `gmake` (the non-GNU `make` will exit with an error).
#### Test Suite Dependencies
There is an included test suite that is useful for testing code changes when developing.
To run the test suite (recommended), you will need to have Python 3 installed:

Preparation:
```bash

# Adapt the following for the version you installed (major.minor only):
export AUTOCONF_VERSION=2.71
export AUTOMAKE_VERSION=1.16

./autogen.sh
pkg_add install python # Select the newest version of the package.
```

## Building Bitcoin Core

### 1. Configuration

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 `qt5` are installed.
This enables descriptor wallet support and the GUI, assuming SQLite and Qt 5 are installed.

```bash
./configure MAKE=gmake
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
./configure --with-gui=no \
BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" \
BDB_CFLAGS="-I${BDB_PREFIX}/include" \
MAKE=gmake
cmake -B build -DBerkeleyDB_INCLUDE_DIR:PATH="${BDB_PREFIX}/include"
```

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

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

## Resource limits
Expand Down
Loading

0 comments on commit 2b7c0f4

Please sign in to comment.