Parcourir la source

Fix detection of -Wno flags to not spam on errors

Bryan Drewery il y a 8 ans
Parent
commit
8c9017bac9
3 fichiers modifiés avec 32 ajouts et 2 suppressions
  1. 1 1
      build/autotools/configure.ac
  2. 30 0
      build/autotools/includes/acinclude.m4
  3. 1 1
      configure

+ 1 - 1
build/autotools/configure.ac

@@ -33,7 +33,7 @@ if [[ "${HAVE_CXX11}" -eq 0 ]]; then
 fi
 CXX_FLAG_CHECK([CXXFLAGS], [-fcolor-diagnostics], [colordiagnostics])
 #CXX_FLAG_CHECK([CXXFLAGS], [-Qunused-arguments], [unusedarguments])
-CXX_FLAG_CHECK([CXXFLAGS], [-Wno-invalid-source-encoding], [invalid_source_encoding])
+CXX_FLAG_CHECK_NO([CXXFLAGS], [-Winvalid-source-encoding], [-Wno-invalid-source-encoding], [invalid_source_encoding])
 CXX_FLAG_CHECK([CXXFLAGS], [-fstack-protector], [stackprotector])
 CXX_FLAG_CHECK([CXXFLAGS], [-fstack-protector-strong], [stackprotectorstrong])
 if [[ "${ax_cv_prog_cc_stackprotectorstrong}" = "yes" ]]; then

+ 30 - 0
build/autotools/includes/acinclude.m4

@@ -211,6 +211,36 @@ EOF
   fi
 ])
 
+dnl @synopsis CXX_FLAG_CHECK_NO [var] [compiler flags] [no flag] [cache name] [required]
+dnl @summary check whether compiler supports given C++ flags or not
+AC_DEFUN([CXX_FLAG_CHECK_NO],
+[
+  AC_CACHE_CHECK([whether the compiler understands $3], ax_cv_prog_cc_$4, [
+    AC_LANG_PUSH([C++])
+    ac_saved_flags="$CXXFLAGS"
+    CXXFLAGS="-Werror $2"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+      [ax_cv_prog_cc_$4="yes"],
+      [ax_cv_prog_cc_$4="no"],
+    )
+    CXXFLAGS="$ac_saved_flags"
+    AC_LANG_POP([C++])
+  ])
+
+  if [[ "$ax_cv_prog_cc_$4" = "yes" ]]; then
+    $1="$$1 $3"
+  elif [[ -n "$5" ]]; then
+      cat << 'EOF' >&2
+configure: error:
+
+  Your OS or C++ compiler does not support $3.
+  This compile flag is required.
+
+EOF
+    exit 1
+  fi
+])
+
 dnl @synopsis CXX_FLAG_CHECK_LINK [var] [compiler flags] [cache name] [required]
 dnl @summary check whether linker supports given C++ flags or not
 AC_DEFUN([CXX_FLAG_CHECK_LINK],

+ 1 - 1
configure

@@ -3482,7 +3482,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
     ac_saved_flags="$CXXFLAGS"
-    CXXFLAGS="-Werror -Wno-invalid-source-encoding"
+    CXXFLAGS="-Werror -Winvalid-source-encoding"
     cat build/confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end build/confdefs.h.  */