Skip to content

Commit 430da15

Browse files
committed
Libc (macOS): detect libSystem version
1 parent 1188db9 commit 430da15

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ elseif(APPLE)
546546
src/detection/host/host_apple.c
547547
src/detection/lm/lm_nosupport.c
548548
src/detection/icons/icons_nosupport.c
549-
src/detection/libc/libc_nosupport.c
549+
src/detection/libc/libc_apple.c
550550
src/detection/localip/localip_linux.c
551551
src/detection/gamepad/gamepad_apple.c
552552
src/detection/media/media_apple.m
@@ -670,6 +670,13 @@ if(LINUX AND EXISTS "/lib/ld-musl-${CMAKE_HOST_SYSTEM_PROCESSOR}.so.1")
670670
target_compile_definitions(libfastfetch PUBLIC FF_MUSL_VERSION="${CMAKE_MATCH_1}")
671671
endif()
672672
endif()
673+
if(APPLE AND EXISTS "/usr/bin/otool")
674+
execute_process(COMMAND /usr/bin/otool -L /usr/bin/otool
675+
OUTPUT_VARIABLE OTOOL_OTOOL_RESULT)
676+
if("${OTOOL_OTOOL_RESULT}" MATCHES "libSystem\\.B\\.dylib \\(.*current version ([0-9]+\\.[0-9]+\\.[0-9]+)\\)")
677+
target_compile_definitions(libfastfetch PUBLIC FF_LIBSYSTEM_VERSION="${CMAKE_MATCH_1}")
678+
endif()
679+
endif()
673680

674681
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__=1)
675682
if(WIN32)

src/detection/libc/libc_apple.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "libc.h"
2+
3+
const char* ffDetectLibc(FFLibcResult* result)
4+
{
5+
result->name = "libSystem";
6+
7+
#ifdef FF_LIBSYSTEM_VERSION
8+
result->version = FF_LIBSYSTEM_VERSION;
9+
#else
10+
result->version = NULL;
11+
#endif
12+
return NULL;
13+
}

0 commit comments

Comments
 (0)