summaryrefslogtreecommitdiff
path: root/infrastructure/m4/boxbackup_tests.m4
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2017-02-27 21:57:41 +0000
committerChris Wilson <chris+github@qwirx.com>2018-03-08 22:20:47 +0000
commit4a9c1e9f305ae4317cdd05d2641db2da86eef615 (patch)
tree1d7313772efe8ab9969af4f542c1dba1cd3393b2 /infrastructure/m4/boxbackup_tests.m4
parent9f53912f0967a4077c8c41f80d6d52b15b007a4c (diff)
Add support for M4 CXX flag detection in CMakeLists
Enables all flags that are detected by M4 builds to be detected by CMake builds as well (except for -Wall which enables a bunch of junk). (cherry picked from commit 2ea8a9706d79a386729c7b2d814089e90bac6926) (cherry picked from commit c6038419372534dba578da0c1b506bebc64f8f67)
Diffstat (limited to 'infrastructure/m4/boxbackup_tests.m4')
-rw-r--r--infrastructure/m4/boxbackup_tests.m435
1 files changed, 18 insertions, 17 deletions
diff --git a/infrastructure/m4/boxbackup_tests.m4 b/infrastructure/m4/boxbackup_tests.m4
index 74a870e9..86aa560a 100644
--- a/infrastructure/m4/boxbackup_tests.m4
+++ b/infrastructure/m4/boxbackup_tests.m4
@@ -10,27 +10,28 @@ solaris*)
;;
esac
+# If the compiler supports it, force errors on unknown flags, so that detection works:
+AX_CHECK_COMPILE_FLAG(-Werror=unknown-warning-option,
+ [cxxflags_force_error="-Werror=unknown-warning-option"])
+
+# Reduce compiler flag checking to a one-liner, needed for CMake to parse them
+AC_DEFUN([BOX_CHECK_CXX_FLAG],
+ AX_CHECK_COMPILE_FLAG($1,
+ [cxxflags_strict="$cxxflags_strict $1"],,
+ $cxxflags_force_error)
+)
+
# Enable some compiler flags if the compiler supports them. This gives better warnings
# and detects some problems early.
-AX_CHECK_COMPILE_FLAG(-Wall, [cxxflags_strict="$cxxflags_strict -Wall"])
-# -Wundef would be a good idea, but Boost is full of undefined variable use, so we need
-# to disable it for now so that we can concentrate on real errors:
-dnl AX_CHECK_COMPILE_FLAG(-Wundef, [cxxflags_strict="$cxxflags_strict -Wundef"])
-AX_CHECK_COMPILE_FLAG(-Werror=return-type,
- [cxxflags_strict="$cxxflags_strict -Werror=return-type"])
-AX_CHECK_COMPILE_FLAG(-Werror=delete-non-virtual-dtor,
- [cxxflags_strict="$cxxflags_strict -Werror=delete-non-virtual-dtor"])
-AX_CHECK_COMPILE_FLAG(-Werror=undefined-bool-conversion,
- [cxxflags_strict="$cxxflags_strict -Werror=undefined-bool-conversion"])
-# We should really enable -Werror=sometimes-uninitialized, but QDBM violates it:
-dnl AX_CHECK_COMPILE_FLAG(-Werror=sometimes-uninitialized,
-dnl [cxxflags_strict="$cxxflags_strict -Werror=sometimes-uninitialized"])
+BOX_CHECK_CXX_FLAG(-Wall)
+BOX_CHECK_CXX_FLAG(-Werror=return-type)
+BOX_CHECK_CXX_FLAG(-Werror=delete-non-virtual-dtor)
+BOX_CHECK_CXX_FLAG(-Werror=undefined-bool-conversion)
# This error is detected by MSVC, but not usually by GCC/Clang:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58114
-AX_CHECK_COMPILE_FLAG(-Werror=delete-incomplete,
- [cxxflags_strict="$cxxflags_strict -Werror=delete-incomplete"])
-AX_CHECK_COMPILE_FLAG(-Wno-deprecated-declarations,
- [cxxflags_strict="$cxxflags_strict -Wno-deprecated-declarations"])
+BOX_CHECK_CXX_FLAG(-Werror=delete-incomplete)
+BOX_CHECK_CXX_FLAG(-Wno-deprecated-declarations)
+
AC_SUBST([CXXFLAGS_STRICT], [$cxxflags_strict])
if test "x$GXX" = "xyes"; then