Add CMake compile instructions for macOS

This commit is contained in:
Steffen Winter 2023-12-05 01:00:14 +01:00
parent 97b35d9720
commit f4b14ce97e
No known key found for this signature in database
GPG Key ID: D4053C3600EF3B1F
1 changed files with 13 additions and 39 deletions

View File

@ -326,7 +326,7 @@ Also needs a UTF8 locale and a font that covers:
## Compilation Linux ## Compilation Linux
Needs GCC 10 / Clang 16 (or higher). Requires at least GCC 10 or Clang 16.
The makefile also needs GNU coreutils and `sed` (should already be installed on any modern distribution). The makefile also needs GNU coreutils and `sed` (should already be installed on any modern distribution).
@ -359,11 +359,9 @@ Also needs a UTF8 locale and a font that covers:
``` ```
<details> <details>
<summary> <summary>
### With Make ### With Make
</summary> </summary>
1. **Install dependencies (example for Ubuntu 21.04 Hirsute)** 1. **Install dependencies (example for Ubuntu 21.04 Hirsute)**
@ -451,11 +449,9 @@ Also needs a UTF8 locale and a font that covers:
</details> </details>
<details> <details>
<summary> <summary>
### With CMake (Community maintained) ### With CMake (Community maintained)
</summary> </summary>
1. **Install build dependencies** 1. **Install build dependencies**
@ -498,7 +494,7 @@ Also needs a UTF8 locale and a font that covers:
| `-DBTOP_RSMI_STATIC=<ON\|OFF>` | Build and link the ROCm SMI library statically (OFF by default) | | `-DBTOP_RSMI_STATIC=<ON\|OFF>` | Build and link the ROCm SMI library statically (OFF by default) |
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) | | `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
To force a compiler, run `CXX=<compiler> cmake -B build -G Ninja` To force any other compiler, run `CXX=<compiler> cmake -B build -G Ninja`
4. **Install** 4. **Install**
@ -525,7 +521,7 @@ Also needs a UTF8 locale and a font that covers:
## Compilation macOS OSX ## Compilation macOS OSX
Needs GCC 10 / Clang 16 (or higher). Requires at least GCC 10 or Clang 16.
With GCC, version 12 (or better) is needed for macOS Ventura. If you get linker errors on Ventura you'll need to upgrade your command line tools (Version 14.0) is bugged. With GCC, version 12 (or better) is needed for macOS Ventura. If you get linker errors on Ventura you'll need to upgrade your command line tools (Version 14.0) is bugged.
@ -534,11 +530,9 @@ Also needs a UTF8 locale and a font that covers:
Install and use Homebrew or MacPorts package managers for easy dependency installation Install and use Homebrew or MacPorts package managers for easy dependency installation
<details> <details>
<summary> <summary>
### With Make ### With Make
</summary> </summary>
1. **Install dependencies (example for Homebrew)** 1. **Install dependencies (example for Homebrew)**
@ -621,30 +615,20 @@ Also needs a UTF8 locale and a font that covers:
</details> </details>
<details> <details>
<summary> <summary>
### With CMake (Community maintained) ### With CMake (Community maintained)
</summary> </summary>
1. **Install build dependencies** 1. **Install build dependencies**
Requires Clang / GCC, CMake, Ninja and Git Requires Clang, CMake, Ninja and Git
_**Note**: Since btop uses C++ 20 features the compiler choice is important._
With LLVM:
```bash ```bash
brew update --quiet brew update --quiet
brew install llvm@17 ninja brew install cmake git llvm ninja
``` ```
With GCC:
```bash
brew update --quiet
brew install gcc@13
2. **Clone the repository** 2. **Clone the repository**
```bash ```bash
@ -653,21 +637,18 @@ Also needs a UTF8 locale and a font that covers:
3. **Compile** 3. **Compile**
FreeBSD 14 and later:
```bash ```bash
# Configure # Configure
export LLVM_PREFIX="$(brew --prefix llvm)"
export CXX="$LLVM_PREFIX/bin/clang++"
export CPPFLAGS="-I$LLVM_PREFIX/include"
export LDFLAGS="-L$LLVM_PREFIX/lib -L$LLVM_PREFIX/lib/c++ -Wl,-rpath,$LLVM_PREFIX/lib/c++ -fuse-ld=$LLVM_PREFIX/bin/ld64.lld"
cmake -B build -G Ninja cmake -B build -G Ninja
# Build # Build
cmake --build build cmake --build build
``` ```
FreeBSD 13: _**Note:** btop uses lots of C++ 20 features, so it's necessary to be specific about the compiler and the standard library. If you get a compile with Apple-Clang or GCC, feel free to add the instructions here._
```bash
# Configure
CXX=g++13 cmake -B build -G Ninja
# Build
cmake --build build
```
This will automatically build a release version of btop. This will automatically build a release version of btop.
@ -675,16 +656,13 @@ Also needs a UTF8 locale and a font that covers:
| Configure flag | Description | | Configure flag | Description |
|---------------------------------|-------------------------------------------------------------------------| |---------------------------------|-------------------------------------------------------------------------|
| `-DBTOP_STATIC=<ON\|OFF>` | Enables static linking (OFF by default) |
| `-DBTOP_LTO=<ON\|OFF>` | Enables link time optimization (ON by default) | | `-DBTOP_LTO=<ON\|OFF>` | Enables link time optimization (ON by default) |
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) | | `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) | | `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) | | `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) | | `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
_**Note:** Static linking does not work with GCC._ To force any specific compiler, run `CXX=<compiler> cmake -B build -G Ninja`
To force a compiler, run `CXX=<compiler> cmake -B build -G Ninja`
4. **Install** 4. **Install**
@ -711,16 +689,14 @@ Also needs a UTF8 locale and a font that covers:
## Compilation FreeBSD ## Compilation FreeBSD
Needs GCC 10 / Clang 16 (or higher). Requires at least GCC 10 or Clang 16.
Note that GNU make (`gmake`) is required to compile on FreeBSD. Note that GNU make (`gmake`) is required to compile on FreeBSD.
<details> <details>
<summary> <summary>
### With gmake ### With gmake
</summary> </summary>
1. **Install dependencies** 1. **Install dependencies**
@ -804,11 +780,9 @@ Also needs a UTF8 locale and a font that covers:
</details> </details>
<details> <details>
<summary> <summary>
### With CMake (Community maintained) ### With CMake (Community maintained)
</summary> </summary>
1. **Install build dependencies** 1. **Install build dependencies**
@ -866,7 +840,7 @@ Also needs a UTF8 locale and a font that covers:
_**Note:** Static linking does not work with GCC._ _**Note:** Static linking does not work with GCC._
To force a compiler, run `CXX=<compiler> cmake -B build -G Ninja` To force any other compiler, run `CXX=<compiler> cmake -B build -G Ninja`
4. **Install** 4. **Install**