Skip to content

Commit fa46dce

Browse files
committed
CMake: detect uclibc and musl version
1 parent 2e60f34 commit fa46dce

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,15 @@ if(yyjson_FOUND)
663663
target_link_libraries(libfastfetch PRIVATE yyjson)
664664
endif()
665665

666+
if(LINUX AND EXISTS "/lib/ld-musl-x86_64.so.1")
667+
execute_process(COMMAND "/lib/ld-musl-x86_64.so.1"
668+
ERROR_VARIABLE LD_MUSL_VERSION)
669+
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" LD_MUSL_VERSION "${LD_MUSL_VERSION}")
670+
if(NOT LD_MUSL_VERSION STREQUAL "")
671+
target_compile_definitions(libfastfetch PUBLIC FF_MUSL_VERSION="${LD_MUSL_VERSION}")
672+
endif()
673+
endif()
674+
666675
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__=1)
667676
if(WIN32)
668677
target_compile_definitions(libfastfetch PUBLIC WIN32_LEAN_AND_MEAN=1)

src/detection/libc/libc_linux.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77

88
const char* ffDetectLibc(FFLibcResult* result)
99
{
10-
#ifdef __GNU_LIBRARY__
10+
#ifdef __UCLIBC__
11+
result->name = "uClibc";
12+
result->version = FF_STR(__UCLIBC_MAJOR__) "." FF_STR(__UCLIBC_MINOR__) "." FF_STR(__UCLIBC_SUBLEVEL__);
13+
#elif defined(__GNU_LIBRARY__)
1114
result->name = "glibc";
1215
result->version = FF_STR(__GLIBC__) "." FF_STR(__GLIBC_MINOR__);
1316
#else
1417
result->name = "musl";
15-
result->version = NULL;
18+
#ifdef FF_MUSL_VERSION
19+
result->version = FF_MUSL_VERSION;
20+
#else
21+
result->version = NULL;
22+
#endif
1623
#endif
1724

1825
return NULL;

0 commit comments

Comments
 (0)