mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-28 14:11:35 +02:00
Add GPU options for cmake based builds
This commit is contained in:
parent
7588d96dd4
commit
2f59e61d87
@ -32,11 +32,14 @@ set(CMAKE_COLOR_DIAGNOSTICS ON)
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
include(CMakeDependentOption)
|
||||||
option(BTOP_STATIC "Link btop statically" OFF)
|
option(BTOP_STATIC "Link btop statically" OFF)
|
||||||
option(BTOP_LTO "Enable LTO" ON)
|
option(BTOP_LTO "Enable LTO" ON)
|
||||||
option(BTOP_USE_MOLD "Use mold to link btop" OFF)
|
option(BTOP_USE_MOLD "Use mold to link btop" OFF)
|
||||||
option(BTOP_PEDANTIC "Enable a bunch of additional warnings" OFF)
|
option(BTOP_PEDANTIC "Enable a bunch of additional warnings" OFF)
|
||||||
option(BTOP_WERROR "Compile with warnings as errors" 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)
|
||||||
# Set this before calling find_package
|
# Set this before calling find_package
|
||||||
@ -130,6 +133,36 @@ target_compile_definitions(btop PRIVATE
|
|||||||
$<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>
|
$<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Enable GPU support
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "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 CMake target (which should've been done by ROCm :-/)
|
||||||
|
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)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(btop SYSTEM PRIVATE include)
|
target_include_directories(btop SYSTEM PRIVATE include)
|
||||||
|
|
||||||
# mold
|
# mold
|
||||||
|
@ -340,7 +340,7 @@ Also needs a UTF8 locale and a font that covers:
|
|||||||
|
|
||||||
For x86_64 Linux the flag `GPU_SUPPORT` is automatically set to `true`, to manually disable gpu support set the flag to false, like:
|
For x86_64 Linux the flag `GPU_SUPPORT` is automatically set to `true`, to manually disable gpu support set the flag to false, like:
|
||||||
|
|
||||||
`make GPU_SUPPORT=false`
|
`make GPU_SUPPORT=false` (or `cmake -DBTOP_GPU=false` with CMake)
|
||||||
|
|
||||||
* **NVIDIA**
|
* **NVIDIA**
|
||||||
|
|
||||||
@ -503,6 +503,8 @@ Also needs a UTF8 locale and a font that covers:
|
|||||||
| `-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) |
|
||||||
|
| `-DBTOP_GPU=<ON\|OFF>` | Enable GPU support (ON 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 a compiler, run `CXX=<compiler> cmake -B build -G Ninja`
|
||||||
|
Loading…
Reference in New Issue
Block a user