GKlib icon indicating copy to clipboard operation
GKlib copied to clipboard

The following addition will make sure GKlib compiles on macOS with gcc

Open gctwnl opened this issue 1 year ago • 0 comments

When gcc is installed on macOS, e.g. via MacPorts, it is often compiled against a specific sysroot. E.g. the current MacPorts gcc14 is compiled against /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk. But on macOS, cmake will get the sysroot from Xcode: Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk

In such a case (as is now the case of GKlib), compiling with gcc will fail, e.g. as gcc's 'stdlib' overrides are incompatible with the given sysroot

This addition in the Makefile will fix this and let cmake pick up the correct sysroot:

*** Makefile	Fri Feb 14 09:55:36 2025
--- Makefile.org	Fri Feb 14 09:55:22 2025
***************
*** 61,64 ****
--- 61,70 ----
      CONFIG_FLAGS += -DNO_X86=$(cputype)
  endif
+ ifeq ($(systype), Darwin)
+     sysroot = $(shell $(cc) -print-sysroot || echo not-set)
+     ifneq ($(sysroot), not-set)
+ 	CONFIG_FLAGS += -DCMAKE_OSX_SYSROOT=$(sysroot)
+     endif
+ endif
  
  define run-config

gctwnl avatar Feb 14 '25 10:02 gctwnl