fix: Guard AppleSilicon GPU code behind __APPLE__ for cross-platform builds

- Wrap AppleSilicon::shutdown() call and declaration with #ifdef __APPLE__
  so Linux GPU builds don't get undefined reference errors
- Add IOReport library linking in CMakeLists.txt for macOS CMake builds
This commit is contained in:
Gary Neitzke
2026-02-14 11:51:21 -08:00
parent 3ec2aeeb01
commit a5179a9b42
3 changed files with 10 additions and 0 deletions

View File

@@ -208,6 +208,12 @@ if(APPLE)
target_link_libraries(libbtop
$<LINK_LIBRARY:FRAMEWORK,CoreFoundation> $<LINK_LIBRARY:FRAMEWORK,IOKit>
)
if(BTOP_GPU)
find_library(IOREPORT_LIB IOReport)
if(IOREPORT_LIB)
target_link_libraries(libbtop ${IOREPORT_LIB})
endif()
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")
# 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

View File

@@ -231,7 +231,9 @@ void clean_quit(int sig) {
#ifdef GPU_SUPPORT
Gpu::Nvml::shutdown();
Gpu::Rsmi::shutdown();
#ifdef __APPLE__
Gpu::AppleSilicon::shutdown();
#endif
#endif

View File

@@ -183,9 +183,11 @@ namespace Gpu {
namespace Rsmi {
extern bool shutdown();
}
#ifdef __APPLE__
namespace AppleSilicon {
extern bool shutdown();
}
#endif
//* Collect gpu stats and temperatures
auto collect(bool no_update = false) -> vector<gpu_info>&;