Commit 45da133999d5946cbb5eabc20dfa55b0aef41e77

Anonymous Maarten 2022-10-06T00:39:47

cmake: don't error on apple when using deprecated declarations

diff --git a/CMakeLists.txt b/CMakeLists.txt
index aba7bf9..4ace591 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -686,6 +686,14 @@ if(USE_GCC OR USE_CLANG)
   endif()
 
   if(APPLE)
+    cmake_push_check_state(RESET)
+    # FIXME: don't use deprecated declarations
+    check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
+    if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
+      target_compile_options(sdl-build-options INTERFACE "-Wno-error=deprecated-declarations")
+    endif()
+    cmake_pop_check_state()
+
     # FIXME: use generator expression instead of appending to EXTRA_LDFLAGS_BUILD
     list(APPEND EXTRA_LDFLAGS_BUILD "-Wl,-undefined,error")
     list(APPEND EXTRA_LDFLAGS_BUILD "-Wl,-compatibility_version,${DYLIB_COMPATIBILITY_VERSION}")
diff --git a/configure b/configure
index cf415a5..8e139dd 100755
--- a/configure
+++ b/configure
@@ -23001,8 +23001,8 @@ printf "%s\n" "$have_gcc_werror" >&6; }
 
 CheckNoErrorDeprecatedDeclarationsWerror()
 {
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Werror option" >&5
-printf %s "checking for GCC -Werror option... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wno-error=deprecated-declarations option" >&5
+printf %s "checking for GCC -Wno-error=deprecated-declarations option... " >&6; }
     have_gcc_no_werror_deprecated_declarations=no
 
     save_CFLAGS="$CFLAGS"
diff --git a/configure.ac b/configure.ac
index 34942b0..2708c1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1622,7 +1622,7 @@ CheckWerror()
 dnl See if GCC's -Wno-error=deprecated-declarations is supported.
 CheckNoErrorDeprecatedDeclarationsWerror()
 {
-    AC_MSG_CHECKING(for GCC -Werror option)
+    AC_MSG_CHECKING(for GCC -Wno-error=deprecated-declarations option)
     have_gcc_no_werror_deprecated_declarations=no
 
     save_CFLAGS="$CFLAGS"
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d7c19f1..9f372bc 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -123,6 +123,13 @@ if(APPLE)
                               testnativecocoa.m
                               testnativex11.c
                               testutils.c)
+
+    cmake_push_check_state(RESET)
+    check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
+    cmake_pop_check_state()
+    if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
+        set_property(SOURCE "testnativecocoa.m" APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error=deprecated-declarations")
+    endif()
 elseif(WINDOWS)
     add_executable(testnative testnative.c testnativew32.c testutils.c)
 elseif(HAVE_X11)
diff --git a/test/configure b/test/configure
index 8b7afb0..c71abe4 100755
--- a/test/configure
+++ b/test/configure
@@ -4790,8 +4790,8 @@ fi
 
 case "$host" in
     *-ios-*|*-*-darwin* )
-        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Werror option" >&5
-printf %s "checking for GCC -Werror option... " >&6; }
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wno-error=deprecated-declarations option" >&5
+printf %s "checking for GCC -Wno-error=deprecated-declarations option... " >&6; }
         have_gcc_wno_error_deprecated_declarations=no
 
         save_CFLAGS="$CFLAGS"
diff --git a/test/configure.ac b/test/configure.ac
index e0dd1c4..e989016 100644
--- a/test/configure.ac
+++ b/test/configure.ac
@@ -241,7 +241,7 @@ fi
 
 case "$host" in
     *-ios-*|*-*-darwin* )
-        AC_MSG_CHECKING(for GCC -Werror option)
+        AC_MSG_CHECKING(for GCC -Wno-error=deprecated-declarations option)
         have_gcc_wno_error_deprecated_declarations=no
 
         save_CFLAGS="$CFLAGS"