|
1 | | -## CMake Build Options |
| 1 | +# CMake Build Options Reference |
2 | 2 |
|
3 | | -You can use GUI (`cmake-gui`) or TUI (`ccmake`) to browse and toggle all |
4 | | -available options: |
| 3 | +This document details the CMake configuration options available for Gridcoin. These flags control which features are compiled, how dependencies are found, and how the final executable is linked. |
5 | 4 |
|
6 | | -```bash |
7 | | -mkdir build && cd build |
8 | | -cmake .. |
9 | | -ccmake . |
10 | | -``` |
| 5 | +## General Configuration |
| 6 | + |
| 7 | +| Option | Default | Description | |
| 8 | +| :--- | :--- | :--- | |
| 9 | +| `CMAKE_BUILD_TYPE` | *Empty* | Controls optimization and debug symbols. Recommended values: `RelWithDebInfo` (Default/Dev), `Release` (Production), `Debug`. If left empty, no optimization is applied. | |
| 10 | +| `ENABLE_GUI` | `OFF` | Builds the Qt-based graphical user interface (`gridcoinresearch`). If `OFF`, only the daemon (`gridcoinresearchd`) is built. | |
| 11 | +| `ENABLE_TESTS` | `OFF` | Builds the unit test suite (`src/test/`). Recommended for all developers. | |
| 12 | +| `ENABLE_DOCS` | `OFF` | Generates Doxygen documentation. | |
| 13 | +| `STATIC_LIBS` | `OFF` | Forces the build system to look for static libraries (`.a`) instead of shared libraries (`.so`). Required for `depends` builds. | |
| 14 | +| `ENABLE_PIE` | `OFF` | Enables Position Independent Executables (PIE) for hardening. Recommended for Linux production builds. | |
| 15 | + |
| 16 | +--- |
11 | 17 |
|
12 | | -### Common configurations |
| 18 | +## Features & Dependencies |
13 | 19 |
|
14 | | -* Build with GUI, QR code support and DBus support: |
| 20 | +These options toggle specific functionality within the Gridcoin client. |
15 | 21 |
|
16 | | - `cmake .. -DENABLE_GUI=ON -DENABLE_QRENCODE=ON -DUSE_DBUS=ON` |
| 22 | +| Option | Default | Why Use It? | Dependencies | |
| 23 | +| :--- | :--- | :--- | :--- | |
| 24 | +| `ENABLE_UPNP` | `OFF` | **Universal Plug and Play.** Allows the client to automatically map ports on your router for incoming connections. Useful for home users behind NAT. | `miniupnpc` | |
| 25 | +| `DEFAULT_UPNP` | `OFF` | If `ENABLE_UPNP` is ON, this sets the default runtime behavior to "Start with UPnP enabled". | `ENABLE_UPNP` | |
| 26 | +| `ENABLE_QRENCODE` | `OFF` | **QR Codes.** Allows the GUI to display QR codes for wallet addresses. Convenient for mobile payments. | `libqrencode` | |
| 27 | +| `USE_DBUS` | `OFF` | **Desktop Bus.** Enables OS notifications on Linux desktops (e.g., "Staked a block!"). | `QtDBus` | |
| 28 | +| `USE_QT6` | `OFF` | Builds against Qt 6 instead of Qt 5. Recommended for modern Linux distributions. | `Qt6` | |
17 | 29 |
|
18 | | -* Build with UPnP: |
| 30 | +--- |
19 | 31 |
|
20 | | - `cmake .. -DENABLE_UPNP=ON -DDEFAULT_UPNP=ON` |
| 32 | +## Advanced / Cross-Compilation |
21 | 33 |
|
22 | | -* Enable PIE and disable assembler routines: |
| 34 | +These options are primarily used by the `depends` system or advanced users. |
23 | 35 |
|
24 | | - `cmake .. -DENABLE_PIE=ON -DUSE_ASM=OFF` |
| 36 | +| Option | Default | Description | |
| 37 | +| :--- | :--- | :--- | |
| 38 | +| `SYSTEM_XXD` | `OFF` | Uses the host system's `xxd` binary instead of building one. **Required** when cross-compiling (e.g., Linux -> Windows). | |
| 39 | +| `SYSTEM_UNIVALUE` | `OFF` | Links against a system-installed `libunivalue` instead of the in-tree submodule. | |
| 40 | +| `SYSTEM_SECP256K1` | `OFF` | Links against a system-installed `libsecp256k1`. | |
| 41 | +| `SYSTEM_LEVELDB` | `OFF` | Links against a system-installed `libleveldb`. | |
| 42 | +| `SYSTEM_BDB` | `OFF` | Links against a system-installed Berkeley DB. *Note: Gridcoin requires BDB 5.3, which is rare in modern distros.* | |
| 43 | + |
| 44 | +## Example Configurations |
| 45 | + |
| 46 | +### Standard Developer Build (Linux) |
| 47 | +```bash |
| 48 | +cmake -B build -DENABLE_GUI=ON -DENABLE_QRENCODE=ON -DUSE_DBUS=ON \ |
| 49 | + -DENABLE_TESTS=ON -DENABLE_UPNP=ON -DDEFAULT_UPNP=ON \ |
| 50 | + -DCMAKE_BUILD_TYPE=RelWithDebInfo |
| 51 | +```` |
25 | 52 |
|
26 | | -* Build a static binary: |
| 53 | +### Minimal GUI Developer Build (Linux) |
| 54 | +```bash |
| 55 | +cmake -B build -DENABLE_GUI=ON -DENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo |
| 56 | +```` |
27 | 57 |
|
28 | | - `cmake .. -DSTATIC_LIBS=ON -DSTATIC_RUNTIME=ON` |
| 58 | +### Minimal GUI Developer Build (Linux) for Detailed Debug |
| 59 | +```bash |
| 60 | +cmake -B build -DENABLE_GUI=ON -DENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug |
| 61 | +``` |
29 | 62 |
|
30 | | -* Build tests and docs, run `lupdate`: |
| 63 | +### Headless Server / Daemon Only |
31 | 64 |
|
32 | | - `cmake .. -DENABLE_DOCS=ON -DENABLE_TESTS=ON -DLUPDATE=ON` |
| 65 | +```bash |
| 66 | +cmake -B build -DENABLE_GUI=OFF -DENABLE_UPNP=OFF -DCMAKE_BUILD_TYPE=Release |
| 67 | +``` |
33 | 68 |
|
34 | | -* Build with system libraries: |
| 69 | +### Full Feature Release |
35 | 70 |
|
36 | | - `cmake .. -DSYSTEM_BDB=ON -DSYSTEM_LEVELDB=ON -DSYSTEM_SECP256K1=ON -DSYSTEM_UNIVALUE=ON -DSYSTEM_XXD=ON` |
| 71 | +```bash |
| 72 | +cmake -B build \ |
| 73 | + -DENABLE_GUI=ON -DENABLE_QRENCODE=ON -DUSE_DBUS=ON \ |
| 74 | + -DENABLE_UPNP=ON -DDEFAULT_UPNP=ON \ |
| 75 | + -DENABLE_PIE=ON \ |
| 76 | + -DCMAKE_BUILD_TYPE=Release |
| 77 | +``` |
0 commit comments