File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
7171cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF )
7272cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR FreeBSD OR ANDROID" OFF )
7373cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF )
74+ cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS" OFF )
7475
7576option (ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embedded) yyjson library" OFF )
7677option (ENABLE_ASAN "Build fastfetch with ASAN (address sanitizer)" OFF )
@@ -1098,6 +1099,25 @@ ff_lib_enable(DIRECTX_HEADERS
10981099 "DirectX-Headers"
10991100 "DirectX-Headers"
11001101)
1102+ # The system <libzfs.h> is only usable on SunOS. We provide our local copy of it so it's always available.
1103+ if (ENABLE_LIBZFS)
1104+ if (BINARY_LINK_TYPE STREQUAL "dlopen" )
1105+ target_compile_definitions (libfastfetch PRIVATE FF_HAVE_LIBZFS=1)
1106+ else ()
1107+ set (CMAKE_REQUIRED_LIBRARIES_BACKUP ${CMAKE_REQUIRED_LIBRARIES} )
1108+ set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} zfs)
1109+ check_function_exists("libzfs_init" LIBZFS_FOUND)
1110+ set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_BACKUP} )
1111+ if (NOT LIBZFS_FOUND)
1112+ message (STATUS "Library: missing: LIBZFS" )
1113+ else ()
1114+ message (STATUS "Library: found LIBZFS" )
1115+ target_compile_definitions (libfastfetch PRIVATE FF_HAVE_LIBZFS=1)
1116+ target_link_libraries (libfastfetch PRIVATE zfs)
1117+ endif ()
1118+ endif ()
1119+ endif ()
1120+
11011121
11021122if (ENABLE_THREADS)
11031123 target_compile_definitions (libfastfetch PRIVATE FF_HAVE_THREADS)
Original file line number Diff line number Diff line change @@ -247,6 +247,9 @@ void ffListFeatures(void)
247247 #if FF_HAVE_ELF
248248 "libelf\n"
249249 #endif
250+ #if FF_HAVE_LIBZFS
251+ "libzfs\n"
252+ #endif
250253 #if FF_HAVE_DIRECTX_HEADERS
251254 "Directx Headers\n"
252255 #endif
Original file line number Diff line number Diff line change 11#include "zpool.h"
22
3+ #ifdef FF_HAVE_LIBZFS
4+
35#ifdef __sun
46#define FF_DISABLE_DLOPEN
57#include <libzfs.h>
@@ -98,3 +100,12 @@ const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */)
98100
99101 return NULL ;
100102}
103+
104+ #else
105+
106+ const char * ffDetectZpool (FF_MAYBE_UNUSED FFlist * result )
107+ {
108+ return "Fastfetch was compiled without libzfs support" ;
109+ }
110+
111+ #endif
You can’t perform that action at this time.
0 commit comments