game-music-emu: Merged in no-undef (pull request #57)

From 2f5a378621f03afd1221491de34a7b16b4e538a1 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 21 Oct 2023 19:25:20 +0300
Subject: [PATCH] handle undefined symbol linker flag separately for APPLE
 targets

---
 gme/CMakeLists.txt | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/gme/CMakeLists.txt b/gme/CMakeLists.txt
index a2f413d..3ee49a2 100644
--- a/gme/CMakeLists.txt
+++ b/gme/CMakeLists.txt
@@ -213,12 +213,16 @@ set(PC_LIBS -lstdc++)
 
 if(NOT MSVC)
     # Link with -no-undefined, if available
-    cmake_push_check_state()
-    set(CMAKE_REQUIRED_FLAGS "-Wl,-no-undefined")
-    check_cxx_source_compiles("int main(void) { return 0;}" LINKER_SUPPORTS_NO_UNDEFINED)
-    cmake_pop_check_state()
-    if(LINKER_SUPPORTS_NO_UNDEFINED)
+    if(APPLE)
+      set_property(TARGET gme APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-undefined,error")
+    else()
+      cmake_push_check_state()
+      set(CMAKE_REQUIRED_FLAGS "-Wl,-no-undefined")
+      check_cxx_source_compiles("int main(void) { return 0;}" LINKER_SUPPORTS_NO_UNDEFINED)
+      cmake_pop_check_state()
+      if(LINKER_SUPPORTS_NO_UNDEFINED)
         set_property(TARGET gme APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-no-undefined")
+      endif()
     endif()
 
     # Link to libm, if necessary