diff --git a/.github/workflows/cmake-freebsd.yml b/.github/workflows/cmake-freebsd.yml new file mode 100644 index 0000000..6e687f1 --- /dev/null +++ b/.github/workflows/cmake-freebsd.yml @@ -0,0 +1,40 @@ +name: FreeBSD CMake + +on: + push: + branches: main + tags-ignore: '*.*' + paths: + - '.github/workflows/cmake-freebsd.yml' + - 'CMakeLists.txt' + - 'include/**' + - 'src/*pp' + - 'src/freebsd/*pp' + pull_request: + branches: main + paths: + - '.github/workflows/cmake-freebsd.yml' + - 'CMakeLists.txt' + - 'include/**' + - 'src/*pp' + - 'src/freebsd/*pp' + +jobs: + cmake_build_on_freebsd: + runs-on: ubuntu-22.04 + concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + + - name: Compile + uses: vmactions/freebsd-vm@v1 + with: + release: '14.0' + usesh: true + prepare: pkg install -y cmake ninja + run: | + CXX=clang++ cmake -B build -G Ninja -DBTOP_STATIC=ON + cmake --build build --verbose + diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml new file mode 100644 index 0000000..49754d9 --- /dev/null +++ b/.github/workflows/cmake-linux.yml @@ -0,0 +1,40 @@ +name: Linux CMake + +on: + push: + branches: main + tags-ignore: '*.*' + paths: + - '.github/workflows/cmake-linux.yml' + - 'CMakeLists.txt' + - 'include/**' + - 'src/*pp' + - 'src/linux/*pp' + pull_request: + branches: main + paths: + - '.github/workflows/cmake-linux.yml' + - 'CMakeLists.txt' + - 'include/**' + - 'src/*pp' + - 'src/linux/*pp' + +jobs: + cmake_build_on_linux: + runs-on: ubuntu-latest + container: alpine:edge + concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + + - name: Install build tools + run: apk add --no-cache --update clang cmake lld ninja + + - name: Configure + run: CXX=clang++ LDFLAGS=-fuse-ld=lld cmake -B build -G Ninja -DBTOP_STATIC=ON + + - name: Compile + run: cmake --build build --verbose + diff --git a/.github/workflows/cmake-macos.yml b/.github/workflows/cmake-macos.yml new file mode 100644 index 0000000..32d6f7f --- /dev/null +++ b/.github/workflows/cmake-macos.yml @@ -0,0 +1,47 @@ +name: macOS CMake + +on: + push: + branches: main + tags-ignore: '*.*' + paths: + - '.github/workflows/cmake-macos.yml' + - 'CMakeLists.txt' + - 'include/**' + - 'src/*pp' + - 'src/osx/*pp' + pull_request: + branches: main + paths: + - '.github/workflows/cmake-macos.yml' + - 'CMakeLists.txt' + - 'include/**' + - 'src/*pp' + - 'src/osx/*pp' + +jobs: + cmake_build_on_macos: + runs-on: macos-latest + concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + + - name: Install build tools + run: | + export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 + brew update --quiet + brew install --force --overwrite cmake llvm@17 ninja + + - name: Configure + run: | + 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 + + - name: Compile + run: cmake --build build --verbose + diff --git a/.github/workflows/continuous-build-freebsd.yml b/.github/workflows/continuous-build-freebsd.yml index c7b68ab..041133f 100644 --- a/.github/workflows/continuous-build-freebsd.yml +++ b/.github/workflows/continuous-build-freebsd.yml @@ -58,18 +58,3 @@ jobs: path: 'bin/*' if-no-files-found: error - build-freebsd-cmake: - runs-on: ubuntu-22.04 - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - - name: Compile - uses: vmactions/freebsd-vm@v1 - with: - release: '14.0' - usesh: true - prepare: pkg install -y cmake git ninja - run: | - CXX=clang++ cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBTOP_STATIC=ON - cmake --build build diff --git a/CMakeLists.txt b/CMakeLists.txt index b808160..3f8c546 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,8 +70,8 @@ else() message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} is not supported") endif() -check_include_file_cxx(ranges CXX_HAS_RANGES) -if(NOT CXX_HAS_RANGES) +check_include_file_cxx(ranges CXX_HAVE_RANGES) +if(NOT CXX_HAVE_RANGES) message(FATAL_ERROR "The compiler doesn't support ") endif() diff --git a/README.md b/README.md index 5d124cc..5eecfce 100644 --- a/README.md +++ b/README.md @@ -450,7 +450,6 @@ Also needs a UTF8 locale and a font that covers: ``` -
@@ -526,14 +525,22 @@ Also needs a UTF8 locale and a font that covers: ## Compilation macOS OSX - Needs GCC 10 or higher, (GCC 11 or above strongly recommended for better CPU efficiency in the compiled binary). + Needs GCC 10 / Clang 16 (or higher). - GCC 12 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. The makefile also needs GNU coreutils and `sed`. Install and use Homebrew or MacPorts package managers for easy dependency installation +
+ + + +### With Make + + + 1. **Install dependencies (example for Homebrew)** ```bash @@ -612,9 +619,99 @@ Also needs a UTF8 locale and a font that covers: gmake help ``` +
+
+ + + +### With CMake (Community maintained) + + + +1. **Install build dependencies** + + Requires Clang / GCC, CMake, Ninja and Git + + _**Note**: Since btop uses C++ 20 features the compiler choice is important._ + + With LLVM: + ```bash + brew update --quiet + brew install llvm@17 ninja + ``` + + With GCC: + ```bash + brew update --quiet + brew install gcc@13 + +2. **Clone the repository** + + ```bash + git clone https://github.com/aristocratos/btop.git && cd btop + ``` + +3. **Compile** + + FreeBSD 14 and later: + ```bash + # Configure + 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 + ``` + + This will automatically build a release version of btop. + + Some useful options to pass to the configure step: + + | Configure flag | Description | + |---------------------------------|-------------------------------------------------------------------------| + | `-DBTOP_STATIC=` | Enables static linking (OFF by default) | + | `-DBTOP_LTO=` | Enables link time optimization (ON by default) | + | `-DBTOP_USE_MOLD=` | Use mold to link btop (OFF by default) | + | `-DBTOP_PEDANTIC=` | Compile with additional warnings (OFF by default) | + | `-DBTOP_WERROR=` | Compile with warnings as errors (OFF by default) | + | `-DCMAKE_INSTALL_PREFIX=` | The installation prefix ('/usr/local' by default) | + + _**Note:** Static linking does not work with GCC._ + + To force a compiler, run `CXX= cmake -B build -G Ninja` + +4. **Install** + + ```bash + cmake --install build + ``` + + May require root privileges + +5. **Uninstall** + + CMake doesn't generate an uninstall target by default. To remove installed files, run + ``` + cat build/install_manifest.txt | xargs rm -irv + ``` + +6. **Cleanup build directory** + + ```bash + cmake --build build -t clean + ``` + +
+ ## Compilation FreeBSD - Needs GCC 10 or higher, (GCC 11 or above strongly recommended for better CPU efficiency in the compiled binary). + Needs GCC 10 / Clang 16 (or higher). Note that GNU make (`gmake`) is required to compile on FreeBSD. @@ -706,7 +803,6 @@ Also needs a UTF8 locale and a font that covers: ```
-
@@ -735,7 +831,7 @@ Also needs a UTF8 locale and a font that covers: ```bash git clone https://github.com/aristocratos/btop.git && cd btop - `````` + ``` 3. **Compile**