Skip to content

Commit

Permalink
Add CMake compile instructions for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
imwints committed Dec 5, 2023
1 parent 97b35d9 commit f4b14ce
Showing 1 changed file with 13 additions and 39 deletions.
52 changes: 13 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Also needs a UTF8 locale and a font that covers:

## 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).

Expand Down Expand Up @@ -359,11 +359,9 @@ Also needs a UTF8 locale and a font that covers:
```

<details>

<summary>

### With Make

</summary>

1. **Install dependencies (example for Ubuntu 21.04 Hirsute)**
Expand Down Expand Up @@ -451,11 +449,9 @@ Also needs a UTF8 locale and a font that covers:

</details>
<details>

<summary>

### With CMake (Community maintained)

</summary>

1. **Install build dependencies**
Expand Down Expand Up @@ -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) |
| `-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**
Expand All @@ -525,7 +521,7 @@ Also needs a UTF8 locale and a font that covers:
## 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.
Expand All @@ -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
<details>
<summary>
### With Make
</summary>
1. **Install dependencies (example for Homebrew)**
Expand Down Expand Up @@ -621,30 +615,20 @@ Also needs a UTF8 locale and a font that covers:
</details>
<details>
<summary>
### With CMake (Community maintained)
</summary>
1. **Install build dependencies**
Requires Clang / GCC, CMake, Ninja and Git
_**Note**: Since btop uses C++ 20 features the compiler choice is important._
Requires Clang, CMake, Ninja and Git
With LLVM:
```bash
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**
```bash
Expand All @@ -653,38 +637,32 @@ Also needs a UTF8 locale and a font that covers:
3. **Compile**
FreeBSD 14 and later:
```bash
# 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
# Build
cmake --build build
```
FreeBSD 13:
```bash
# Configure
CXX=g++13 cmake -B build -G Ninja
# Build
cmake --build build
```
_**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._
This will automatically build a release version of btop.
Some useful options to pass to the configure step:
| 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_USE_MOLD=<ON\|OFF>` | Use mold to link btop (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) |
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
_**Note:** Static linking does not work with GCC._
To force a compiler, run `CXX=<compiler> cmake -B build -G Ninja`
To force any specific compiler, run `CXX=<compiler> cmake -B build -G Ninja`
4. **Install**
Expand All @@ -711,16 +689,14 @@ Also needs a UTF8 locale and a font that covers:
## 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.
<details>
<summary>
### With gmake
</summary>
1. **Install dependencies**
Expand Down Expand Up @@ -804,11 +780,9 @@ Also needs a UTF8 locale and a font that covers:
</details>
<details>
<summary>
### With CMake (Community maintained)
</summary>
1. **Install build dependencies**
Expand Down Expand Up @@ -866,7 +840,7 @@ Also needs a UTF8 locale and a font that covers:
_**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**
Expand Down

0 comments on commit f4b14ce

Please sign in to comment.