From 45da133999d5946cbb5eabc20dfa55b0aef41e77 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 6 Oct 2022 00:39:47 +0200 Subject: [PATCH] cmake: don't error on apple when using deprecated declarations --- CMakeLists.txt | 8 ++++++++ configure | 4 ++-- configure.ac | 2 +- test/CMakeLists.txt | 7 +++++++ test/configure | 4 ++-- test/configure.ac | 2 +- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aba7bf9ca..4ace59161 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 cf415a596..8e139dd08 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 34942b0dc..2708c1f76 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 d7c19f175..9f372bc77 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 8b7afb01e..c71abe489 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 e0dd1c463..e9890163e 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"