Use the QMAKE_CXXFLAGS_WARN_ON variable for setting -Werror

This would mean we don't pass -Werror when under CONFIG += warn_off.
However, that's not the main goal. The main goal of this change is to
have -Werror appear *after* -Wall -Wextra.

With some compilers, like Clang, this is necessary to have the
-Wno-error=foo options work properly. For example, if the -Wfoo
warning gets enabled by -Wall, Clang will treat it as an error if the
arguments appear in the following order:
   -Werror -Wno-error=foo -Wall

But not if they appear in this order:
   -Wall -Werror -Wno-error=foo

Change-Id: I38c820bffc8277d909391e9bf557db5347836b9c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Thiago Macieira 2014-01-03 21:22:45 -02:00 committed by The Qt Project
parent d19eef3bbb
commit 81157d2374

View File

@ -32,10 +32,10 @@ warnings_are_errors:warning_clean {
apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION}
reg_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}
contains(apple_ver, "4\\.[012]")|contains(reg_ver, "3\\.[34]") {
QMAKE_CXXFLAGS += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR
QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR
# glibc's bswap_XX macros use the "register" keyword
linux: QMAKE_CXXFLAGS += -Wno-error=deprecated-register
linux:equals(reg_ver, "3.4"): QMAKE_CXXFLAGS_WARN_ON += -Wno-error=deprecated-register
}
} else:intel_icc:linux {
# Intel CC 13.0 - 14.0, on Linux only
@ -47,20 +47,20 @@ warnings_are_errors:warning_clean {
# 1478: function "entity" (declared at line N) was declared deprecated
# 1881: argument must be a constant null pointer value
# (NULL in C++ is usually a literal 0)
QMAKE_CXXFLAGS += -Werror -ww177,1224,1478,1881 $$WERROR
QMAKE_CXXFLAGS_WARN_ON += -Werror -ww177,1224,1478,1881 $$WERROR
}
} else:gcc:!clang:!intel_icc {
# GCC 4.6-4.8
ver = $${QT_GCC_MAJOR_VERSION}.$${QT_GCC_MINOR_VERSION}
contains(ver, "4\\.[678]") {
QMAKE_CXXFLAGS += -Werror -Wno-error=cpp -Wno-error=deprecated-declarations $$WERROR
QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=cpp -Wno-error=deprecated-declarations $$WERROR
# GCC prints this bogus warning, after it has inlined a lot of code
# error: assuming signed overflow does not occur when assuming that (X + c) < X is always false
QMAKE_CXXFLAGS += -Wno-error=strict-overflow
QMAKE_CXXFLAGS_WARN_ON += -Wno-error=strict-overflow
# Work-around for bug https://code.google.com/p/android/issues/detail?id=58135
android: QMAKE_CXXFLAGS += -Wno-error=literal-suffix
android: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=literal-suffix
}
}
unset(ver)