From ebb0cf77bdfbb55a07216938f862f3c3ec247bea Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 13 Jun 2026 08:26:27 +0800 Subject: [PATCH] CMake: checks linux kernel headers --- CMakeLists.txt | 7 +++++++ src/common/impl/init.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index acadb6b5b..92544f9a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,13 @@ endif() include(CheckIncludeFile) +if(LINUX) + CHECK_INCLUDE_FILE("linux/version.h" HAVE_LINUX_VERSION_H) + if(NOT HAVE_LINUX_VERSION_H) + message(FATAL_ERROR "Linux headers (linux/version.h) not found! Please install linux-headers package.") + endif() +endif() + ##################### # Configure options # ##################### diff --git a/src/common/impl/init.c b/src/common/impl/init.c index 9cebbbe7b..ff1a398bc 100644 --- a/src/common/impl/init.c +++ b/src/common/impl/init.c @@ -17,6 +17,9 @@ #else #include #endif +#if __linux__ + #include +#endif FFinstance instance; // Global singleton @@ -190,6 +193,9 @@ void ffDestroyInstance(void) { // Must be in a file compiled with the libfastfetch target, because the FF_HAVE* macros are not defined for the executable targets void ffListFeatures(void) { fputs( +#if __linux__ + "linux-headers " FF_STR(LINUX_VERSION_MAJOR) "." FF_STR(LINUX_VERSION_PATCHLEVEL) "." FF_STR(LINUX_VERSION_SUBLEVEL) "\n" +#endif #if FF_HAVE_THREADS "threads\n" #endif