From f17dcbed31a2fce634d53027bbfab667d1210428 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Fri, 7 Aug 2026 03:15:32 +0000
Subject: [PATCH 01/38] CMakeLists: relax warnings-as-errors and trim Apple
 frameworks/sources for legacy PowerPC builds

Downgrade several -Werror flags to -Wno-error, disable -rdynamic on Apple,
and swap unsupported detection modules (bluetooth, brightness, gamepad,
media, poweradapter, wifi) to their nosupport variants for legacy targets.
Drop frameworks not available pre-10.7 (Metal, AVFoundation, CoreWLAN,
OpenCL, VideoToolbox, weak-linked private frameworks).

Ported from https://github.com/macos-powerpc/powerpc-ports/blob/main/sysutils/fastfetch/files/0012-Misc-fixes-for-legacy-systems.patch
---
 CMakeLists.txt | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4cd0df0d1..9a70e899a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -180,7 +180,7 @@ else()
     message(STATUS "Threads type: disabled")
 endif()
 
-set(WARNING_FLAGS "-Wall -Wextra -Wconversion -Werror=uninitialized -Werror=return-type -Werror=vla")
+set(WARNING_FLAGS "-Wall -Wextra -Wconversion -Wno-error=uninitialized -Werror=return-type -Werror=vla")
 
 if(LINUX)
     if(NOT IS_MUSL) # `NOT DEFINED IS_MUSL` doesn't work
@@ -206,7 +206,7 @@ endif()
 # Most C23 features are allowed with noticeable exceptions of `constexpr` and `#embed`
 # See https://cppreference.com/c/compiler_support/23 for detail
 set(CMAKE_C_STANDARD 23)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} -Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=int-conversion")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration -Werror=int-conversion")
 
 if(WIN32 OR Haiku)
     enable_language(CXX)
@@ -237,7 +237,7 @@ if(ENABLE_ASAN)
 endif()
 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}")
 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG} -fstack-protector-all -fno-delete-null-pointer-checks")
-if(NOT WIN32)
+if(NOT WIN32 AND NOT APPLE)
     set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -rdynamic")
 endif()
 
@@ -1013,10 +1013,10 @@ elseif(APPLE)
         src/common/apple/smc_temps.c
         src/common/apple/version.m
         src/detection/battery/battery_apple.c
-        src/detection/bluetooth/bluetooth_apple.m
-        src/detection/bluetoothradio/bluetoothradio_apple.m
+        src/detection/bluetooth/bluetooth_nosupport.c
+        src/detection/bluetoothradio/bluetoothradio_nosupport.c
         src/detection/bootmgr/bootmgr_apple.c
-        src/detection/brightness/brightness_apple.c
+        src/detection/brightness/brightness_nosupport.c
         src/detection/btrfs/btrfs_nosupport.c
         src/detection/codec/codec_apple.c
         src/detection/cpu/cpu_apple.c
@@ -1039,8 +1039,8 @@ elseif(APPLE)
         src/detection/libc/libc_apple.c
         src/detection/locale/locale_linux.c
         src/detection/localip/localip_linux.c
-        src/detection/gamepad/gamepad_apple.c
-        src/detection/media/media_apple.m
+        src/detection/gamepad/gamepad_nosupport.c
+        src/detection/media/media_nosupport.c
         src/detection/memory/memory_apple.c
         src/detection/mouse/mouse_apple.c
         src/detection/netio/netio_apple.c
@@ -1048,7 +1048,7 @@ elseif(APPLE)
         src/detection/os/os_apple.m
         src/detection/packages/packages_apple.c
         src/detection/packages/packages_nix.c
-        src/detection/poweradapter/poweradapter_apple.c
+        src/detection/poweradapter/poweradapter_nosupport.c
         src/detection/processes/processes_bsd.c
         src/detection/sound/sound_apple.c
         src/detection/swap/swap_apple.c
@@ -1060,7 +1060,7 @@ elseif(APPLE)
         src/detection/uptime/uptime_bsd.c
         src/detection/users/users_linux.c
         src/detection/wallpaper/wallpaper_apple.m
-        src/detection/wifi/wifi_apple.m
+        src/detection/wifi/wifi_nosupport.c
         src/detection/wm/wm_apple.m
         src/detection/de/de_nosupport.c
         src/detection/wmtheme/wmtheme_apple.m
@@ -1885,25 +1885,17 @@ if(LINUX)
     endif()
 elseif(APPLE)
     target_link_libraries(libfastfetch
-        PRIVATE "-framework AVFoundation"
         PRIVATE "-framework Cocoa"
         PRIVATE "-framework CoreFoundation"
         PRIVATE "-framework CoreAudio"
         PRIVATE "-framework CoreMedia"
         PRIVATE "-framework CoreVideo"
-        PRIVATE "-framework CoreWLAN"
         PRIVATE "-framework IOBluetooth"
         PRIVATE "-framework IOKit"
-        PRIVATE "-framework Metal"
         PRIVATE "-framework OpenGL"
-        PRIVATE "-framework OpenCL"
         PRIVATE "-framework SystemConfiguration"
-        PRIVATE "-framework VideoToolbox"
-        PRIVATE "-weak_framework CoreDisplay"
-
-        PRIVATE "-F /System/Library/PrivateFrameworks"
-        PRIVATE "-weak_framework DisplayServices"
-        PRIVATE "-weak_framework MediaRemote"
+        PRIVATE "-framework DisplayServices"
+        PRIVATE "-F/System/Library/PrivateFrameworks"
     )
 elseif(WIN32)
     target_link_libraries(libfastfetch
-- 
2.43.0

