From e35538fa29e7975a6ca92bb2c0fd0e36d8108ba5 Mon Sep 17 00:00:00 2001 From: Steffen Winter Date: Sat, 2 Dec 2023 00:34:32 +0100 Subject: [PATCH 1/8] Patch RPATH on FreeBSD, support OSX and format --- CMakeLists.txt | 131 +++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce4891d..b808160 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ # CMake configuration for btop # -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.24) # Disable in-source builds since they would override the Makefile if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") @@ -17,7 +17,12 @@ project("btop" LANGUAGES CXX ) -# Make custom modules available +include(CheckCXXCompilerFlag) +include(CheckIncludeFileCXX) +include(CheckIPOSupported) +include(CMakeDependentOption) + +# Make our Find.cmake files available list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") # When the build type is not set we can't fortify @@ -31,8 +36,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_COLOR_DIAGNOSTICS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# Options -include(CMakeDependentOption) option(BTOP_STATIC "Link btop statically" OFF) option(BTOP_LTO "Enable LTO" ON) option(BTOP_USE_MOLD "Use mold to link btop" OFF) @@ -41,20 +44,11 @@ option(BTOP_WERROR "Compile with warnings as errors" OFF) option(BTOP_GPU "Enable GPU support" ON) cmake_dependent_option(BTOP_RSMI_STATIC "Link statically to ROCm SMI" OFF "BTOP_GPU" OFF) -if(BTOP_STATIC) +if(BTOP_STATIC AND NOT APPLE) # Set this before calling find_package set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") endif() -include(CheckCXXCompilerFlag) -include(CheckIncludeFileCXX) -include(CheckIPOSupported) - -check_include_file_cxx(ranges CXX_HAS_RANGES) -if(NOT CXX_HAS_RANGES) - message(FATAL_ERROR "The compiler doesn't support ") -endif() - add_executable(btop src/btop.cpp src/btop_config.cpp @@ -66,106 +60,98 @@ add_executable(btop src/btop_tools.cpp ) -# NOTE: Checks can be simplified with CMake 3.25 -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - target_sources(btop PRIVATE - src/osx/btop_collect.cpp - src/osx/sensors.cpp - src/osx/smc.cpp - ) +if(APPLE) + target_sources(btop PRIVATE src/osx/btop_collect.cpp src/osx/sensors.cpp src/osx/smc.cpp) elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") target_sources(btop PRIVATE src/freebsd/btop_collect.cpp) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") +elseif(LINUX) target_sources(btop PRIVATE src/linux/btop_collect.cpp) else() message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} is not supported") endif() +check_include_file_cxx(ranges CXX_HAS_RANGES) +if(NOT CXX_HAS_RANGES) + message(FATAL_ERROR "The compiler doesn't support ") +endif() + # Check for and enable LTO check_ipo_supported(RESULT ipo_supported) if(ipo_supported AND BTOP_LTO) set_target_properties(btop PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON) endif() -# TODO: enable more warnings in coordination with upstream -target_compile_options(btop PRIVATE - -Wall -Wextra -Wpedantic - -ftree-vectorize -fstack-clash-protection -) -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_options(btop PRIVATE - -Wheader-hygiene -Wgnu -Wthread-safety - ) -endif() +target_compile_options(btop PRIVATE -Wall -Wextra -Wpedantic -ftree-vectorize) if(BTOP_PEDANTIC) target_compile_options(btop PRIVATE - -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused - -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion - -Wformat=2 -Wimplicit-fallthrough -Weffc++ + -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual + -Wconversion -Wsign-conversion -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Weffc++ + $<$:-Wheader-hygiene -Wgnu -Wthread-safety> + $<$:-Wduplicated-cond -Wduplicated-branches -Wlogical-op> + $<$:-Wnull-dereference -Wuseless-cast> ) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(btop PRIVATE - -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference - -Wuseless-cast - ) - endif() endif() - if(BTOP_WERROR) target_compile_options(btop PRIVATE -Werror) endif() -check_cxx_compiler_flag(-fstack-protector CXX_HAS_FSTACK_PROTECTOR) -if(CXX_HAS_FSTACK_PROTECTOR) +if(NOT APPLE) + target_compile_options(btop PRIVATE -fstack-clash-protection) +endif() +check_cxx_compiler_flag(-fstack-protector HAS_FSTACK_PROTECTOR) +if(HAS_FSTACK_PROTECTOR) target_compile_options(btop PRIVATE -fstack-protector) endif() - -check_cxx_compiler_flag(-fcf-protection CXX_HAS_FCF_PROTECTION) -if(CXX_HAS_FCF_PROTECTION) +check_cxx_compiler_flag(-fcf-protection HAS_FCF_PROTECTION) +if(HAS_FCF_PROTECTION) target_compile_options(btop PRIVATE -fcf-protection) endif() target_compile_definitions(btop PRIVATE _FILE_OFFSET_BITS=64 - _GLIBCXX_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS=1 + $<$:_GLIBCXX_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS=1> # Only has an effect with optimizations enabled $<$>:_FORTIFY_SOURCE=2> ) +target_include_directories(btop SYSTEM PRIVATE include) + +# Enable pthreads +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) +target_link_libraries(btop Threads::Threads) + # Enable GPU support -if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND BTOP_GPU) +if(LINUX AND BTOP_GPU) target_compile_definitions(btop PRIVATE GPU_SUPPORT) if(BTOP_RSMI_STATIC) - # ROCm doesn't properly add it's folders to the module path - # if `CMAKE_MODULE_PATH` is already set + # ROCm doesn't properly add it's folders to the module path if `CMAKE_MODULE_PATH` is already + # set # We could also manully append ROCm's path here set(_CMAKE_MODULE_PATH CMAKE_MODULE_PATH) unset(CMAKE_MODULE_PATH) - # NOTE: This might be problematic in the future if other sub projects - # depend on this or if btop starts producing libraries + # NOTE: This might be problematic in the future if other sub projects depend on this or if + # btop starts producing libraries # Build a static ROCm library set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) add_subdirectory(lib/rocm_smi_lib EXCLUDE_FROM_ALL) add_library(ROCm INTERFACE) - # Export ROCm's properties to a CMake target (which should've been done by ROCm :-/) + # Export ROCm's properties to a target target_compile_definitions(ROCm INTERFACE RSMI_STATIC) target_include_directories(ROCm INTERFACE lib/rocm_smi_lib/include) target_link_libraries(ROCm INTERFACE rocm_smi64) set(CMAKE_MODULE_PATH _CMAKE_MODULE_PATH) - target_link_libraries(btop PRIVATE ROCm) + target_link_libraries(btop ROCm) endif() endif() -target_include_directories(btop SYSTEM PRIVATE include) - -# mold if(BTOP_USE_MOLD) target_link_options(btop PRIVATE -fuse-ld=mold) endif() @@ -175,21 +161,28 @@ if(BTOP_STATIC) target_link_options(btop PRIVATE -static LINKER:--fatal-warnings) endif() -# Add libraries -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) -target_link_libraries(btop PRIVATE Threads::Threads) - -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - target_link_libraries(btop PRIVATE $ $ + ) elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + # Avoid version mismatch for libstdc++ when a specific version of GCC is installed and not the + # default one since all use the default ones RPATH + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + string(REGEX MATCH "^[0-9]+" GCC_VERSION_MAJOR "${CMAKE_CXX_COMPILER_VERSION}") + set_target_properties(btop PROPERTIES + INSTALL_RPATH "/usr/local/lib/gcc${GCC_VERSION_MAJOR}" + BUILD_WITH_INSTALL_RPATH TRUE + ) + endif() + find_package(devstat REQUIRED) - find_package(kvm REQUIRED) - target_link_libraries(btop PRIVATE devstat::devstat kvm::kvm) + target_link_libraries(btop devstat::devstat) if(BTOP_STATIC) find_package(elf REQUIRED) - target_link_libraries(btop PRIVATE elf::elf) + find_package(kvm REQUIRED) + target_link_libraries(btop elf::elf kvm::kvm) endif() endif() From 97b35d97206417a5170324f7d98b815bec002b36 Mon Sep 17 00:00:00 2001 From: Steffen Winter Date: Sat, 2 Dec 2023 00:35:13 +0100 Subject: [PATCH 2/8] Add cmake workflow for all platforms --- .github/workflows/cmake-freebsd.yml | 40 +++++++ .github/workflows/cmake-linux.yml | 40 +++++++ .github/workflows/cmake-macos.yml | 47 ++++++++ .../workflows/continuous-build-freebsd.yml | 15 --- CMakeLists.txt | 4 +- README.md | 108 +++++++++++++++++- 6 files changed, 231 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/cmake-freebsd.yml create mode 100644 .github/workflows/cmake-linux.yml create mode 100644 .github/workflows/cmake-macos.yml 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** From f4b14ce97e35d439bcc3207c3eb78da442c92fa9 Mon Sep 17 00:00:00 2001 From: Steffen Winter Date: Tue, 5 Dec 2023 01:00:14 +0100 Subject: [PATCH 3/8] Add CMake compile instructions for macOS --- README.md | 52 +++++++++++++--------------------------------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 5eecfce..47f8f08 100644 --- a/README.md +++ b/README.md @@ -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). @@ -359,11 +359,9 @@ Also needs a UTF8 locale and a font that covers: ```
- ### With Make - 1. **Install dependencies (example for Ubuntu 21.04 Hirsute)** @@ -451,11 +449,9 @@ Also needs a UTF8 locale and a font that covers:
- ### With CMake (Community maintained) - 1. **Install build dependencies** @@ -498,7 +494,7 @@ Also needs a UTF8 locale and a font that covers: | `-DBTOP_RSMI_STATIC=` | Build and link the ROCm SMI library statically (OFF by default) | | `-DCMAKE_INSTALL_PREFIX=` | The installation prefix ('/usr/local' by default) | - To force a compiler, run `CXX= cmake -B build -G Ninja` + To force any other compiler, run `CXX= cmake -B build -G Ninja` 4. **Install** @@ -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. @@ -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
- ### With Make - 1. **Install dependencies (example for Homebrew)** @@ -621,30 +615,20 @@ Also needs a UTF8 locale and a font that covers:
- ### With CMake (Community maintained) - 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 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 @@ -653,21 +637,18 @@ 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. @@ -675,16 +656,13 @@ Also needs a UTF8 locale and a font that covers: | 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` + To force any specific compiler, run `CXX= cmake -B build -G Ninja` 4. **Install** @@ -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.
- ### With gmake - 1. **Install dependencies** @@ -804,11 +780,9 @@ Also needs a UTF8 locale and a font that covers:
- ### With CMake (Community maintained) - 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._ - To force a compiler, run `CXX= cmake -B build -G Ninja` + To force any other compiler, run `CXX= cmake -B build -G Ninja` 4. **Install** From 0246b1b971a3f991540acd72ef66b5481d9bc76f Mon Sep 17 00:00:00 2001 From: Muneeb Ahmed <32603485+muneebmahmed@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:18:40 -0800 Subject: [PATCH 4/8] Enable macos clang Apple clang uses different versioning from LLVM, so 15.0.0 is compatible --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2adc8c2..970e818 100644 --- a/Makefile +++ b/Makefile @@ -59,10 +59,14 @@ override CXX_VERSION_MAJOR := $(shell echo $(CXX_VERSION) | cut -d '.' -f 1) CLANG_WORKS = false GCC_WORKS = false +MIN_CLANG_VERSION = 16 #? Supported is Clang 16.0.0 and later ifeq ($(CXX_IS_CLANG),true) - ifneq ($(shell test $(CXX_VERSION_MAJOR) -lt 16; echo $$?),0) + ifeq ($(shell $(CXX) --version | grep Apple >/dev/null 2>&1; echo $$?),0) + MIN_CLANG_VERSION := 15 + endif + ifneq ($(shell test $(CXX_VERSION_MAJOR) -lt $(MIN_CLANG_VERSION); echo $$?),0) CLANG_WORKS := true endif endif From e770cccaf82cb75fe1e61c227284929e5a4acde1 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 12 Dec 2023 22:55:48 +0100 Subject: [PATCH 5/8] Added try->catch for get_zfs_stat_file() to avoid fs error --- src/linux/btop_collect.cpp | 39 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index ab4574f..a9bdc50 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -1936,29 +1936,32 @@ namespace Mem { } // looking through all files that start with 'objset' to find the one containing `device_name` object stats - for (const auto& file: fs::directory_iterator(zfs_pool_stat_path)) { - filename = file.path().filename(); - if (filename.starts_with("objset")) { - filestream.open(file.path()); - if (filestream.good()) { - // skip first two lines - for (int i = 0; i < 2; i++) filestream.ignore(numeric_limits::max(), '\n'); - // skip characters until '7' is reached, indicating data type 7, next value will be object name - filestream.ignore(numeric_limits::max(), '7'); - filestream >> name_compare; - if (name_compare == device_name) { - filestream.close(); - if (access(file.path().c_str(), R_OK) == 0) { - return file.path(); - } else { - Logger::debug("Can't access file: " + file.path().string()); - return ""; + try { + for (const auto& file: fs::directory_iterator(zfs_pool_stat_path)) { + filename = file.path().filename(); + if (filename.starts_with("objset")) { + filestream.open(file.path()); + if (filestream.good()) { + // skip first two lines + for (int i = 0; i < 2; i++) filestream.ignore(numeric_limits::max(), '\n'); + // skip characters until '7' is reached, indicating data type 7, next value will be object name + filestream.ignore(numeric_limits::max(), '7'); + filestream >> name_compare; + if (name_compare == device_name) { + filestream.close(); + if (access(file.path().c_str(), R_OK) == 0) { + return file.path(); + } else { + Logger::debug("Can't access file: " + file.path().string()); + return ""; + } } } + filestream.close(); } - filestream.close(); } } + catch (fs::filesystem_error& e) {} Logger::debug("Could not read directory: " + zfs_pool_stat_path.string()); return ""; From a017056ea07f6532b333f3e6f10a023505fb0470 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 12 Dec 2023 23:05:07 +0100 Subject: [PATCH 6/8] Added swap to ignore for statvfs() since it will always fail --- src/linux/btop_collect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index a9bdc50..33a0be8 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -1755,7 +1755,7 @@ namespace Mem { //? Get disk/partition stats for (auto it = disks.begin(); it != disks.end(); ) { auto &[mountpoint, disk] = *it; - if (v_contains(ignore_list, mountpoint)) { + if (v_contains(ignore_list, mountpoint) or disk.name == "swap") { it = disks.erase(it); continue; } From d7b581eda4560e969459d5f4a1e0ef811e5a08be Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 12 Dec 2023 23:17:36 +0100 Subject: [PATCH 7/8] Updated changes --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c82b0f3..bbf273b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ * Added Gpu Support | @romner-set | PR #529 +* Enable macos clang | @muneebmahmed | PR #666 + +* Fix Apple Silicon CPUs misprinted | @masiboss | PR #679 + +* Cmake support for MacOS | @imwints | PR #675 + * Elementarish theme: color update according to Elementary palette | @stradicat | PR #660 * Add alternative key codes for Delete, Insert, Home, End | @ivanp7 | PR #659 From fe699b433398818cf2145d2ca4d2e364a089a4d2 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 12 Dec 2023 23:20:09 +0100 Subject: [PATCH 8/8] Version bump to 1.3.0 in preparation for upcoming release --- src/btop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/btop.cpp b/src/btop.cpp index b58127c..252f2a9 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -75,7 +75,7 @@ namespace Global { {"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"}, {"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"}, }; - const string Version = "1.2.13"; + const string Version = "1.3.0"; int coreCount; string overlay;