mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:24:58 +02:00
Make it possible to build without optional dependencies
This commit is contained in:
+40
-16
@@ -43,31 +43,55 @@ configure_file(src/fastfetch_config.h.in fastfetch_config.h)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package (PkgConfig)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
if(${PkgConfig_FOUND})
|
||||
pkg_check_modules (GIO2 gio-2.0)
|
||||
pkg_check_modules (DCONF dconf)
|
||||
endif(${PkgConfig_FOUND})
|
||||
pkg_check_modules (GIO2 gio-2.0)
|
||||
if(GIO2_FOUND)
|
||||
add_compile_definitions(FF_HAS_GIO2=1)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED GIO2_INCLUDE_DIRS)
|
||||
set(GIO2_INCLUDE_DIRS
|
||||
/usr/include/glib-2.0/
|
||||
/usr/lib/glib-2.0/include/
|
||||
)
|
||||
endif(NOT DEFINED GIO2_INCLUDE_DIRS)
|
||||
pkg_check_modules (DCONF dconf)
|
||||
if(DCONF_FOUND)
|
||||
add_compile_definitions(FF_HAS_DCONF=1)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED DCONF_INCLUDE_DIRS)
|
||||
set(DCONF_INCLUDE_DIRS
|
||||
/usr/include/dconf/
|
||||
)
|
||||
endif(NOT DEFINED DCONF_INCLUDE_DIRS)
|
||||
pkg_check_modules (XFCONF xfconf)
|
||||
if(XFCONF_FOUND)
|
||||
add_compile_definitions(FF_HAS_XFCONF=1)
|
||||
endif()
|
||||
|
||||
pkg_check_modules (XRANDR xrandr)
|
||||
if(XRANDR_FOUND)
|
||||
add_compile_definitions(FF_HAS_XRANDR=1)
|
||||
endif()
|
||||
|
||||
pkg_check_modules (X11 x11)
|
||||
if(X11_FOUND)
|
||||
add_compile_definitions(FF_HAS_X11=1)
|
||||
endif()
|
||||
|
||||
pkg_check_modules (WAYLAND wayland-client)
|
||||
if(WAYLAND_FOUND)
|
||||
add_compile_definitions(FF_HAS_WAYLAND=1)
|
||||
endif()
|
||||
|
||||
pkg_check_modules (SQLITE3 sqlite3)
|
||||
if(SQLITE3_FOUND)
|
||||
add_compile_definitions(FF_HAS_SQLITE3=1)
|
||||
endif()
|
||||
|
||||
pkg_check_modules (LIBPCI REQUIRED libpci)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_BINARY_DIR}
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${GIO2_INCLUDE_DIRS}
|
||||
${DCONF_INCLUDE_DIRS}
|
||||
${XRANDR_INCLUDE_DIRS}
|
||||
${X11_INCLUDE_DIRS}
|
||||
${WAYLAND_INCLUDE_DIRS}
|
||||
${SQLITE3_INCLUDE_DIRS}
|
||||
${LIBPCI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_libraries(
|
||||
|
||||
+27
-3
@@ -2,8 +2,12 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <dconf.h> // Also included gio/gio.h
|
||||
#include <sqlite3.h>
|
||||
#if FF_HAS_DCONF
|
||||
# include <dconf.h> // Also included gio/gio.h
|
||||
#endif
|
||||
#if FF_HAS_SQLITE3
|
||||
# include <sqlite3.h>
|
||||
#endif
|
||||
|
||||
typedef void* DynamicLibrary;
|
||||
|
||||
@@ -25,6 +29,7 @@ typedef void* DynamicLibrary;
|
||||
if(dlerror() != NULL) \
|
||||
FF_LIBRARY_ERROR_RETURN(library, mutex, returnValue)
|
||||
|
||||
#if FF_HAS_DCONF
|
||||
typedef struct GVariantGetters
|
||||
{
|
||||
const gchar*(*ffg_variant_get_string)(GVariant*, gsize*);
|
||||
@@ -261,9 +266,23 @@ FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, con
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getXFConfValue(&data, channelName, propertyName, type);
|
||||
}
|
||||
|
||||
#else
|
||||
FFvariant ffSettingsGet(FFinstance*, const char*, const char*, const char*, const char*, FFvarianttype) {
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
FFvariant ffSettingsGetDConf(FFinstance*, const char*, FFvarianttype) {
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
FFvariant ffSettingsGetXFConf(FFinstance*, const char*, const char*, FFvarianttype) {
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
FFvariant ffSettingsGetGSettings(FFinstance*, const char*, const char*, const char*, FFvarianttype) {
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
#endif // FF_HAS_DCONF
|
||||
#undef FF_VARIANT_NULL
|
||||
|
||||
#if FF_HAS_SQLITE3
|
||||
typedef struct SQLiteData
|
||||
{
|
||||
int(*ffsqlite3_open_v2)(const char* filename, sqlite3** ppDb, int flags, const char* zVfs);
|
||||
@@ -355,3 +374,8 @@ uint32_t ffSettingsGetSQLiteColumnCount(FFinstance* instance, const char* fileNa
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getSQLiteColumnCount(&data, fileName, tableName);
|
||||
}
|
||||
#else
|
||||
uint32_t ffSettingsGetSQLiteColumnCount(FFinstance*, const char*, const char*) {
|
||||
return 0;
|
||||
}
|
||||
#endif // FF_HAS_SQLITE3
|
||||
|
||||
@@ -4,8 +4,16 @@
|
||||
#include <dlfcn.h>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#if FF_HAS_X11
|
||||
# include <X11/Xlib.h>
|
||||
#endif
|
||||
#if FF_HAS_XRANDR
|
||||
# include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
#if FF_HAS_WAYLAND
|
||||
# include <wayland-client.h>
|
||||
#endif
|
||||
|
||||
#define FF_RESOLUTION_MODULE_NAME "Resolution"
|
||||
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
|
||||
@@ -61,6 +69,7 @@ static bool printResolutionResultList(FFinstance* instance, FFlist* results)
|
||||
return res;
|
||||
}
|
||||
|
||||
#if FF_HAS_XRANDR || FF_HAS_WAYLAND
|
||||
static int parseRefreshRate(int32_t refreshRate)
|
||||
{
|
||||
if(refreshRate <= 0)
|
||||
@@ -78,6 +87,7 @@ static int parseRefreshRate(int32_t refreshRate)
|
||||
|
||||
return refreshRate;
|
||||
}
|
||||
#endif // FF_HAS_XRANDR || FF_HAS_WAYLAND
|
||||
|
||||
static void printResolutionDRMBackend(FFinstance* instance)
|
||||
{
|
||||
@@ -139,6 +149,7 @@ static void printResolutionDRMBackend(FFinstance* instance)
|
||||
printResolutionResultList(instance, &modes);
|
||||
}
|
||||
|
||||
#if FF_HAS_X11
|
||||
static void x11AddScreenAsResult(FFlist* results, Screen* screen, int refreshRate)
|
||||
{
|
||||
if(WidthOfScreen(screen) == 0 || HeightOfScreen(screen) == 0)
|
||||
@@ -175,7 +186,9 @@ static bool printResolutionX11Backend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &results);
|
||||
}
|
||||
#endif // FF_HAS_XLIB
|
||||
|
||||
#if FF_HAS_XRANDR
|
||||
typedef struct XrandrData
|
||||
{
|
||||
XRRScreenConfiguration*(*ffXRRGetScreenInfo)(Display* display, Window window);
|
||||
@@ -357,7 +370,9 @@ static bool printResolutionXrandrBackend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &data.results);
|
||||
}
|
||||
#endif // FF_HAS_XRANDR
|
||||
|
||||
#if FF_HAS_WAYLAND
|
||||
typedef struct WaylandData
|
||||
{
|
||||
FFinstance* instance;
|
||||
@@ -502,13 +517,21 @@ static bool printResolutionWaylandBackend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &data.results);
|
||||
}
|
||||
#endif // FF_HAS_WAYLAND
|
||||
|
||||
void ffPrintResolution(FFinstance* instance)
|
||||
{
|
||||
if(
|
||||
#if FF_HAS_WAYLAND
|
||||
printResolutionWaylandBackend(instance) ||
|
||||
#endif
|
||||
#if FF_HAS_XRANDR
|
||||
printResolutionXrandrBackend(instance) ||
|
||||
printResolutionX11Backend(instance)
|
||||
#endif
|
||||
#if FF_HAS_X11
|
||||
printResolutionX11Backend(instance) ||
|
||||
#endif
|
||||
false
|
||||
) return;
|
||||
|
||||
printResolutionDRMBackend(instance);
|
||||
|
||||
Reference in New Issue
Block a user