]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Change flags to "-Werror=unguarded-availability", "-Werror=unguarded-availability...
authorVladislav Shchapov <vladislav@shchapov.ru>
Mon, 24 Feb 2025 16:58:59 +0000 (21:58 +0500)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 1 Mar 2025 15:45:04 +0000 (16:45 +0100)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
CMakeLists.txt
configure

index f1bc7ba4cec1f3a39a0949c5fa07fefb98f020a7..73ed22a4211fb1791d610ba494e2b0537343ceae 100644 (file)
@@ -373,6 +373,21 @@ if(MSVC)
     endif()
 endif()
 
+#
+# Additional flags for features checking
+#
+set(ADDITIONAL_CHECK_FLAGS )
+if(APPLE)
+    check_c_compiler_flag(-Werror=unguarded-availability HAVE_W_ERROR_UNGUARDED_AVAILABILITY)
+    if(HAVE_W_ERROR_UNGUARDED_AVAILABILITY)
+        set(ADDITIONAL_CHECK_FLAGS "${ADDITIONAL_CHECK_FLAGS} -Werror=unguarded-availability")
+    endif()
+    check_c_compiler_flag(-Werror=unguarded-availability-new HAVE_W_ERROR_UNGUARDED_AVAILABILITY_NEW)
+    if(HAVE_W_ERROR_UNGUARDED_AVAILABILITY_NEW)
+        set(ADDITIONAL_CHECK_FLAGS "${ADDITIONAL_CHECK_FLAGS} -Werror=unguarded-availability-new")
+    endif()
+endif()
+
 #
 # Check for standard/system includes
 #
@@ -418,31 +433,31 @@ set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
 #
 # Check for fseeko and other optional functions
 #
+set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
 check_function_exists(fseeko HAVE_FSEEKO)
 if(NOT HAVE_FSEEKO)
     add_definitions(-DNO_FSEEKO)
 endif()
+set(CMAKE_REQUIRED_FLAGS)
 
+set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
 check_function_exists(strerror HAVE_STRERROR)
 if(NOT HAVE_STRERROR)
     add_definitions(-DNO_STRERROR)
 endif()
+set(CMAKE_REQUIRED_FLAGS)
 
 set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
+set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
 check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
 if(HAVE_POSIX_MEMALIGN)
     add_definitions(-DHAVE_POSIX_MEMALIGN)
 endif()
+set(CMAKE_REQUIRED_FLAGS)
 set(CMAKE_REQUIRED_DEFINITIONS)
 
 set(CMAKE_REQUIRED_DEFINITIONS -D_ISOC11_SOURCE=1)
-set(CMAKE_REQUIRED_FLAGS)
-if(APPLE)
-    check_c_compiler_flag(-Wunguarded-availability-new HAVE_W_UNGUARDED_AVAILABILITY_NEW)
-    if(HAVE_W_UNGUARDED_AVAILABILITY_NEW)
-        set(CMAKE_REQUIRED_FLAGS "-Wunguarded-availability-new -Werror")
-    endif()
-endif()
+set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
 check_symbol_exists(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
 if(HAVE_ALIGNED_ALLOC)
     add_definitions(-DHAVE_ALIGNED_ALLOC)
index f68e243eae1c22ea67dd40be8f49c6a1c800d0f4..15bb593368b20e642485e06a6b174cbc309e3bb2 100755 (executable)
--- a/configure
+++ b/configure
@@ -632,6 +632,32 @@ fi
 
 echo >> configure.log
 
+ADDITIONAL_CHECK_FLAGS=""
+
+# Check for -Werror=unguarded-availability compiler support
+echo "" > test.c
+  cat > $test.c <<EOF
+int main() { return 0; }
+EOF
+if $cc $CFLAGS -Werror=unguarded-availability -c $test.c >> configure.log 2>&1; then
+  echo "Checking for -Werror=unguarded-availability... Yes." | tee -a configure.log
+  ADDITIONAL_CHECK_FLAGS="$ADDITIONAL_CHECK_FLAGS -Werror=unguarded-availability"
+else
+  echo "Checking for -Werror=unguarded-availability... No." | tee -a configure.log
+fi
+
+# Check for -Werror=unguarded-availability-new compiler support
+echo "" > test.c
+  cat > $test.c <<EOF
+int main() { return 0; }
+EOF
+if $cc $CFLAGS -Werror=unguarded-availability-new -c $test.c >> configure.log 2>&1; then
+  echo "Checking for -Werror=unguarded-availability-new... Yes." | tee -a configure.log
+  ADDITIONAL_CHECK_FLAGS="$ADDITIONAL_CHECK_FLAGS -Werror=unguarded-availability-new"
+else
+  echo "Checking for -Werror=unguarded-availability-new... No." | tee -a configure.log
+fi
+
 # check for version script support
 cat > $test.c <<EOF
 int foo(void) { return 0; }
@@ -688,7 +714,7 @@ int main(void) {
   return 0;
 }
 EOF
-  if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
+  if try $CC $CFLAGS $ADDITIONAL_CHECK_FLAGS -o $test $test.c $LDSHAREDLIBC; then
     echo "Checking for fseeko... Yes." | tee -a configure.log
   else
     CFLAGS="${CFLAGS} -DNO_FSEEKO"
@@ -709,7 +735,7 @@ int main(void) {
   return ret;
 }
 EOF
-if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
+if try $CC $CFLAGS $ADDITIONAL_CHECK_FLAGS -o $test $test.c $LDSHAREDLIBC; then
   echo "Checking for posix_memalign... Yes." | tee -a configure.log
   CFLAGS="${CFLAGS} -DHAVE_POSIX_MEMALIGN"
   SFLAGS="${SFLAGS} -DHAVE_POSIX_MEMALIGN"
@@ -718,18 +744,6 @@ else
 fi
 echo >> configure.log
 
-# Check for -Wunguarded-availability-new compiler support
-echo "" > test.c
-  cat > $test.c <<EOF
-int main() { return 0; }
-EOF
-if $cc $CFLAGS -Wunguarded-availability-new -c $test.c >> configure.log 2>&1; then
-  echo "Checking for -Wunguarded-availability-new... Yes." | tee -a configure.log
-  TEST_ALIGNED_ALLOC_FLAGS="$TEST_ALIGNED_ALLOC_FLAGS -Wunguarded-availability-new -Werror"
-else
-  echo "Checking for -Wunguarded-availability-new... No." | tee -a configure.log
-fi
-
 cat > $test.c <<EOF
 #define _ISOC11_SOURCE 1
 #include <stdlib.h>
@@ -740,7 +754,7 @@ int main(void) {
   return 0;
 }
 EOF
-if try $CC $CFLAGS $TEST_ALIGNED_ALLOC_FLAGS -o $test $test.c $LDSHAREDLIBC; then
+if try $CC $CFLAGS $ADDITIONAL_CHECK_FLAGS -o $test $test.c $LDSHAREDLIBC; then
   echo "Checking for aligned_alloc... Yes." | tee -a configure.log
   CFLAGS="${CFLAGS} -DHAVE_ALIGNED_ALLOC"
   SFLAGS="${SFLAGS} -DHAVE_ALIGNED_ALLOC"
@@ -755,7 +769,7 @@ cat > $test.c <<EOF
 #include <errno.h>
 int main() { return strlen(strerror(errno)); }
 EOF
-if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
+if try $CC $CFLAGS $ADDITIONAL_CHECK_FLAGS -o $test $test.c $LDSHAREDLIBC; then
   echo "Checking for strerror... Yes." | tee -a configure.log
 else
   CFLAGS="${CFLAGS} -DNO_STRERROR"