summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob P. Liljenberg <admin@qvantnet.com>2024-01-03 16:34:01 +0100
committerGitHub <noreply@github.com>2024-01-03 16:34:01 +0100
commitef788efc536733a441949dab854b0a6bea5ef33e (patch)
tree4a27a7212369425705973fc29f9c8feff00b00ba
parentc90e3f9b1508f55d281495468297df409f974eb0 (diff)
parenta29545c4079e9bc5203e09965ac03fabe975bd7e (diff)
Merge branch 'main' into lldb-term-size
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md5
-rw-r--r--.github/workflows/cmake-freebsd.yml40
-rw-r--r--.github/workflows/cmake-linux.yml40
-rw-r--r--.github/workflows/cmake-macos.yml47
-rw-r--r--.github/workflows/continuous-build-freebsd.yml26
-rw-r--r--.github/workflows/continuous-build-linux.yml2
-rw-r--r--.github/workflows/continuous-build-macos.yml8
-rw-r--r--.github/workflows/continuous-build-openbsd.yml58
-rw-r--r--.github/workflows/test-snap-can-build.yml42
-rw-r--r--.gitignore3
-rw-r--r--CHANGELOG.md46
-rw-r--r--CMakeLists.txt147
-rw-r--r--Makefile136
-rw-r--r--README.md385
-rw-r--r--include/robin_hood.h2544
-rw-r--r--snap/snapcraft.yaml3
-rw-r--r--src/btop.cpp117
-rw-r--r--src/btop_config.cpp71
-rw-r--r--src/btop_config.hpp26
-rw-r--r--src/btop_draw.cpp659
-rw-r--r--src/btop_draw.hpp9
-rw-r--r--src/btop_input.cpp33
-rw-r--r--src/btop_input.hpp5
-rw-r--r--src/btop_menu.cpp126
-rw-r--r--src/btop_menu.hpp2
-rw-r--r--src/btop_shared.cpp12
-rw-r--r--src/btop_shared.hpp114
-rw-r--r--src/btop_theme.cpp14
-rw-r--r--src/btop_theme.hpp9
-rw-r--r--src/btop_tools.cpp99
-rw-r--r--src/btop_tools.hpp132
-rw-r--r--src/freebsd/btop_collect.cpp35
-rw-r--r--src/linux/btop_collect.cpp774
-rw-r--r--src/openbsd/btop_collect.cpp1295
-rw-r--r--src/openbsd/internal.h157
-rw-r--r--src/openbsd/sysctlbyname.cpp46
-rw-r--r--src/openbsd/sysctlbyname.h20
-rw-r--r--src/osx/btop_collect.cpp38
-rw-r--r--src/osx/sensors.cpp3
-rw-r--r--src/osx/sensors.hpp3
-rw-r--r--themes/elementarish.theme50
41 files changed, 4319 insertions, 3062 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 3c937d1..7ed6a21 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -29,6 +29,7 @@ Any bug that can be solved by just reading the [prerequisites](https://github.co
**Info (please complete the following information):**
- btop++ version: `btop -v`
+ - If using snap: `snap info btop`
- Binary: [self compiled or static binary from release]
- (If compiled) Compiler and version:
- Architecture: [x86_64, aarch64, etc.] `uname -m`
@@ -40,7 +41,9 @@ Any bug that can be solved by just reading the [prerequisites](https://github.co
**Additional context**
-contents of `~/.config/btop/btop.log`
+Contents of `~/.config/btop/btop.log`
+
+Note: The snap uses: `~/snap/btop/current/.config/btop`
(try running btop with `--debug` flag if btop.log is empty)
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 5caa6d1..d06190f 100644
--- a/.github/workflows/continuous-build-freebsd.yml
+++ b/.github/workflows/continuous-build-freebsd.yml
@@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/osx/**'
+ - '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-freebsd.yml'
@@ -21,34 +22,41 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/osx/**'
+ - '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-freebsd.yml'
jobs:
build-freebsd:
- runs-on: macos-12
+ runs-on: ubuntu-22.04
+ timeout-minutes: 20
+ strategy:
+ matrix:
+ compiler: ["clang++", "g++"]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
submodules: recursive
- name: Compile
- uses: vmactions/freebsd-vm@v0
+ uses: vmactions/freebsd-vm@v1
with:
- release: 13.2
+ release: '14.0'
usesh: true
prepare: |
- pkg install -y gmake gcc11 coreutils git
- git config --global --add safe.directory /Users/runner/work/btop/btop
+ pkg install -y gmake gcc coreutils git
+ git config --global --add safe.directory /home/runner/work/btop/btop
run: |
- gmake STATIC=true STRIP=true
+ CXX=${{ matrix.compiler }} gmake STATIC=true STRIP=true
GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
- mv bin/btop bin/btop-$GIT_HASH
+ COMPILER=$(echo ${{ matrix.compiler }} | sed 's/clang++/llvm/' | sed 's/g++/gcc/')
+ mv bin/btop bin/btop-"$COMPILER"-"$GIT_HASH"
ls -alh bin
- uses: actions/upload-artifact@v3
with:
- name: btop-x86_64-FreeBSD-13.2
+ name: btop-x86_64-freebsd-14
path: 'bin/*'
if-no-files-found: error
+
diff --git a/.github/workflows/continuous-build-linux.yml b/.github/workflows/continuous-build-linux.yml
index 3ef236c..39de640 100644
--- a/.github/workflows/continuous-build-linux.yml
+++ b/.github/workflows/continuous-build-linux.yml
@@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
+ - '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-linux.yml'
@@ -21,6 +22,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
+ - '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-linux.yml'
diff --git a/.github/workflows/continuous-build-macos.yml b/.github/workflows/continuous-build-macos.yml
index 717e9a7..c8915dd 100644
--- a/.github/workflows/continuous-build-macos.yml
+++ b/.github/workflows/continuous-build-macos.yml
@@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/freebsd/**'
+ - '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-macos.yml'
@@ -21,6 +22,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/freebsd/**'
+ - '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-macos.yml'
@@ -44,18 +46,18 @@ jobs:
with:
name: btop-x86_64-macos11-BigSur
path: 'bin/*'
-
+
build-macos12:
runs-on: macos-12
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
- xcode-version: latest-stable
+ xcode-version: latest-stable
- uses: actions/checkout@v3
with:
submodules: recursive
-
+
- name: Compile
run: |
make CXX=g++-12 ARCH=x86_64 STATIC=true STRIP=true
diff --git a/.github/workflows/continuous-build-openbsd.yml b/.github/workflows/continuous-build-openbsd.yml
new file mode 100644
index 0000000..afb1a93
--- /dev/null
+++ b/.github/workflows/continuous-build-openbsd.yml
@@ -0,0 +1,58 @@
+name: Continuous Build OpenBSD
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - main
+ tags-ignore:
+ - '*.*'
+ paths:
+ - 'src/**'
+ - '!src/linux/**'
+ - '!src/osx/**'
+ - '!src/freebsd/**'
+ - 'include/**'
+ - 'Makefile'
+ - '.github/workflows/continuous-build-openbsd.yml'
+ pull_request:
+ branches:
+ - main
+ paths:
+ - 'src/**'
+ - '!src/linux/**'
+ - '!src/osx/**'
+ - '!src/freebsd/**'
+ - 'include/**'
+ - 'Makefile'
+ - '.github/workflows/continuous-build-openbsd.yml'
+
+jobs:
+ build-openbsd:
+ runs-on: ubuntu-22.04
+ timeout-minutes: 20
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ submodules: recursive
+
+ - name: Compile
+ uses: vmactions/openbsd-vm@v1
+ with:
+ release: '7.4'
+ usesh: true
+ prepare: |
+ pkg_add gmake gcc%11 g++%11 coreutils git
+ git config --global --add safe.directory /home/runner/work/btop/btop
+ run: |
+ gmake CXX=eg++ STATIC=true STRIP=true
+ GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
+ mv bin/btop bin/btop-GCC11-"$GIT_HASH"
+ ls -alh bin
+
+ - uses: actions/upload-artifact@v3
+ with:
+ name: btop-x86_64-openbsd-7.4
+ path: 'bin/*'
+ if-no-files-found: error
+
diff --git a/.github/workflows/test-snap-can-build.yml b/.github/workflows/test-snap-can-build.yml
new file mode 100644
index 0000000..c66df73
--- /dev/null
+++ b/.github/workflows/test-snap-can-build.yml
@@ -0,0 +1,42 @@
+name: 🧪 Test snap can be built on x86_64
+
+on:
+ workflow_dispatch:
+ push:
+ branches: [ main ]
+ tags-ignore:
+ - '*.*'
+ paths:
+ - 'src/**'
+ - '!src/osx/**'
+ - '!src/freebsd/**'
+ - 'include/**'
+ - 'Makefile'
+ - '.github/workflows/test-snap-can-build.yml'
+ pull_request:
+ branches: [ main ]
+ paths:
+ - 'src/**'
+ - '!src/osx/**'
+ - '!src/freebsd/**'
+ - 'include/**'
+ - 'Makefile'
+ - '.github/workflows/test-snap-can-build.yml'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [16.x]
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: snapcore/action-build@v1
+ id: build
+
+ - uses: diddlesnaps/snapcraft-review-action@v1
+ with:
+ snap: ${{ steps.build.outputs.snap }}
+ isClassic: 'false'
diff --git a/.gitignore b/.gitignore
index 14aa9cd..7e2ed8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,9 @@ bin
btop
.*/
+# Optional libraries
+lib/rocm_smi_lib
+
# Don't ignore .github directory
!.github/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a4eceb..bbf273b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,49 @@
+## v1.3.0
+
+* 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
+
+* Fix scrollbar not clearing sometimes. | @DecklynKern | PR #643
+
+* Add keybind for toggling memory display mode in PROC box | @rahulaggarwal965 | PR #623
+
+* Minor string initialization improvement | @imwints | PR #636
+
+* Made disks statvfs logic asynchronous. | @crestfallnatwork | PR #633
+
+* Fix signal list on non-linux/weird linux platforms | @lvxnull | PR #630
+
+* Add option to accumulate a child's resources in parent in tree-view | @imwints | PR #618
+
+* Add CMake support for Linux | @imwints | PR #589
+
+* Horizon theme | @SidVeld | PR #610
+
+* Fix short conversion of 1000-1023 *iB | @scorpion-26 | #609
+
+* Fix integer overflows in btop_collect.cpp | @dorrellmw | #546
+
+* Support compiling with LLVM | @imwints | #510
+
+* Fix getting zfs pool name with '.' char in freebsd | @jfouquart | #602
+
+* [macos/freebsd] support gcc13 | @joske | #600
+
+* FreeBSD swap info | @rrveex | #560
+
+* Create adwaita.theme | @flipflop133 | #485
+
++ Various fixes by @imwints, @simplepad, @joske, @gwena, @cpalv, @iambeingtracked, @mattico, @NexAdn
+
## v1.2.13
* Makefile: VERBOSE=true flag for Makefile to display all compiler commands and fixed so already set CXXFLAGS and LDFLAGS are displayed.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d11a250..3f8c546 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@
# CMake configuration for btop
#
-cmake_minimum_required(VERSION 3.12)
+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<Package>.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,29 +36,19 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_COLOR_DIAGNOSTICS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-# Options
option(BTOP_STATIC "Link btop statically" OFF)
option(BTOP_LTO "Enable LTO" ON)
option(BTOP_USE_MOLD "Use mold to link btop" OFF)
option(BTOP_PEDANTIC "Enable a bunch of additional warnings" OFF)
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()
-if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
- find_package(devstat REQUIRED)
- find_package(kvm REQUIRED)
- if(BTOP_STATIC)
- find_package(elf REQUIRED)
- endif()
-endif()
-
-include(CheckCXXCompilerFlag)
-include(CheckIPOSupported)
-
add_executable(btop
src/btop.cpp
src/btop_config.cpp
@@ -65,76 +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_HAVE_RANGES)
+if(NOT CXX_HAVE_RANGES)
+ message(FATAL_ERROR "The compiler doesn't support <ranges>")
+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++
+ $<$<CXX_COMPILER_ID:Clang>:-Wheader-hygiene -Wgnu -Wthread-safety>
+ $<$<CXX_COMPILER_ID:GNU>:-Wduplicated-cond -Wduplicated-branches -Wlogical-op>
+ $<$<CXX_COMPILER_ID:GNU>:-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
+ $<$<CONFIG:Debug>:_GLIBCXX_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS=1>
# Only has an effect with optimizations enabled
$<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>
)
target_include_directories(btop SYSTEM PRIVATE include)
-# mold
+# Enable pthreads
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+target_link_libraries(btop Threads::Threads)
+
+# Enable GPU support
+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
+ # 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
+ # 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 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 ROCm)
+ endif()
+endif()
+
if(BTOP_USE_MOLD)
target_link_options(btop PRIVATE -fuse-ld=mold)
endif()
@@ -144,18 +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 $<LINK_LIBRARY:FRAMEWORK,CoreFoundation)
- target_link_libraries(btop PRIVATE $<LINK_LIBRARY:FRAMEWORK,IOKit)
+# Other platform depdendent flags
+if(APPLE)
+ target_link_libraries(btop
+ $<LINK_LIBRARY:FRAMEWORK,CoreFoundation> $<LINK_LIBRARY:FRAMEWORK,IOKit>
+ )
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
- target_link_libraries(btop PRIVATE devstat::devstat kvm::kvm)
+ # 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)
+ target_link_libraries(btop devstat::devstat)
if(BTOP_STATIC)
- target_link_libraries(btop PRIVATE elf::elf)
+ find_package(elf REQUIRED)
+ find_package(kvm REQUIRED)
+ target_link_libraries(btop elf::elf kvm::kvm)
endif()
endif()
diff --git a/Makefile b/Makefile
index 01e98d5..36e2ea1 100644
--- a/Makefile
+++ b/Makefile
@@ -12,10 +12,7 @@ else
endif
ifneq ($(QUIET),true)
- override PRE := info info-quiet
override QUIET := false
-else
- override PRE := info-quiet
endif
OLDCXX := $(CXXFLAGS)
@@ -39,6 +36,20 @@ endif
override PLATFORM_LC := $(shell echo $(PLATFORM) | tr '[:upper:]' '[:lower:]')
+#? GPU Support
+ifeq ($(PLATFORM_LC)$(ARCH),linuxx86_64)
+ ifneq ($(STATIC),true)
+ GPU_SUPPORT := true
+ endif
+endif
+ifneq ($(GPU_SUPPORT),true)
+ GPU_SUPPORT := false
+endif
+
+ifeq ($(GPU_SUPPORT),true)
+ override ADDFLAGS += -DGPU_SUPPORT
+endif
+
#? Compiler and Linker
ifeq ($(shell $(CXX) --version | grep clang >/dev/null 2>&1; echo $$?),0)
override CXX_IS_CLANG := true
@@ -48,38 +59,23 @@ override CXX_VERSION_MAJOR := $(shell echo $(CXX_VERSION) | cut -d '.' -f 1)
CLANG_WORKS = false
GCC_WORKS = false
+MIN_CLANG_VERSION = 16
+
+ifeq ($(DEBUG),true)
+ override ADDFLAGS += -DBTOP_DEBUG
+endif
#? Supported is Clang 16.0.0 and later
ifeq ($(CXX_IS_CLANG),true)
- ifneq ($(shell test $(CXX_VERSION_MAJOR) -lt 16; echo $$?),0)
- CLANG_WORKS := true
+ ifeq ($(shell $(CXX) --version | grep Apple >/dev/null 2>&1; echo $$?),0)
+ MIN_CLANG_VERSION := 15
endif
-endif
-ifeq ($(CLANG_WORKS),false)
- #? Try to find a newer GCC version
- ifeq ($(shell command -v g++-13 >/dev/null; echo $$?),0)
- CXX := g++-13
- else ifeq ($(shell command -v g++13 >/dev/null; echo $$?),0)
- CXX := g++13
- else ifeq ($(shell command -v g++-12 >/dev/null; echo $$?),0)
- CXX := g++-12
- else ifeq ($(shell command -v g++12 >/dev/null; echo $$?),0)
- CXX := g++12
- else ifeq ($(shell command -v g++-11 >/dev/null; echo $$?),0)
- CXX := g++-11
- else ifeq ($(shell command -v g++11 >/dev/null; echo $$?),0)
- CXX := g++11
- else ifeq ($(shell command -v g++ >/dev/null; echo $$?),0)
- CXX := g++
- else
- GCC_NOT_FOUND := true
+ ifneq ($(shell test $(CXX_VERSION_MAJOR) -lt $(MIN_CLANG_VERSION); echo $$?),0)
+ CLANG_WORKS := true
endif
- ifndef GCC_NOT_FOUND
- override CXX_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion || echo 0)
- override CXX_VERSION_MAJOR := $(shell echo $(CXX_VERSION) | cut -d '.' -f 1)
- ifneq ($(shell test $(CXX_VERSION_MAJOR) -lt 10; echo $$?),0)
- GCC_WORKS := true
- endif
+else
+ ifneq ($(shell test $(CXX_VERSION_MAJOR) -lt 10; echo $$?),0)
+ GCC_WORKS := true
endif
endif
@@ -139,6 +135,12 @@ else ifeq ($(PLATFORM_LC),macos)
THREADS := $(shell sysctl -n hw.ncpu || echo 1)
override ADDFLAGS += -framework IOKit -framework CoreFoundation -Wno-format-truncation
SU_GROUP := wheel
+else ifeq ($(PLATFORM_LC),openbsd)
+ PLATFORM_DIR := openbsd
+ THREADS := $(shell sysctl -n hw.ncpu || echo 1)
+ override ADDFLAGS += -lkvm
+ export MAKE = gmake