diff --git a/configure b/configure index dbc82b4e4783b9bf75a9b69124c40dc6bae452bd..777de4673e188156c3c2a1fd23a8462f9b000581 100755 --- a/configure +++ b/configure @@ -2,6 +2,7 @@ ############################################################################# ## ## Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +## Copyright (C) 2013 Intel Corporation. ## Contact: http://www.qt-project.org/legal ## ## This file is the build configuration utility of the Qt Toolkit. @@ -893,6 +894,7 @@ CFG_PCRE=auto QPA_PLATFORM_GUARD=yes CFG_CXX11=auto CFG_DIRECTWRITE=no +CFG_WERROR=auto # initalize variables used for installation QT_INSTALL_PREFIX= @@ -2138,6 +2140,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + warnings-are-errors|Werror) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_WERROR="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; *) UNKNOWN_OPT=yes ;; @@ -3296,6 +3305,10 @@ Additional options: * -no-system-proxies .. Do not use system network proxies by default. -system-proxies ..... Use system network proxies by default. + -no-warnings-are-errors Make warnings be treated normally + -warnings-are-errors Make warnings be treated as errors + (enabled if -developer-build is active) + $GBN -no-glib ........... Do not compile Glib support. $GBY -glib .............. Compile Glib support. EOF @@ -6098,6 +6111,11 @@ else fi if [ "$CFG_DEV" = "yes" ]; then QT_CONFIG="$QT_CONFIG private_tests" + if [ "$CFG_WERROR" != "no" ]; then + QMAKE_CONFIG="$QMAKE_CONFIG warnings_are_errors" + fi +elif [ "$CFG_WERROR" = "yes" ]; then + QMAKE_CONFIG="$QMAKE_CONFIG warnings_are_errors" fi cat >>"$QTCONFIG.tmp" <<EOF diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index 2400ab0c2c517c8d291ef904f669c0ba2f6e5191..10b7736749309e39fe83ed6e1b5bc836c4a8db89 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -18,3 +18,37 @@ contains(TEMPLATE, .*lib) { contains(QT_CONFIG, separate_debug_info): CONFIG += separate_debug_info contains(QT_CONFIG, separate_debug_info_nocopy): CONFIG += separate_debug_info_nocopy } + +warnings_are_errors:warning_clean { + # If the module declares that it has does its clean-up of warnings, enable -Werror. + # This setting is compiler-dependent anyway because it depends on the version of the + # compiler. + clang { + # Apple clang 4.0+ or clang 3.1+ + greaterThan(QT_CLANG_MAJOR_VERSION, 3) | \ + if(equals(QT_CLANG_MAJOR_VERSION, 3):greaterThan(QT_CLANG_MINOR_VERSION, 1)) | \ + greaterThan(QT_APPLE_CLANG_MAJOR_VERSION, 3) { + QMAKE_CXXFLAGS += -Werror -Wno-error=\\$${LITERAL_HASH}warnings $$WERROR + } + } else:intel_icc { + # Intel CC 13.0+ (a.k.a. Intel Composer XE 2013) + greaterThan(QT_ICC_MAJOR_VERSION, 12) { + # 177: function "entity" was declared but never referenced + # (too aggressive; ICC reports even for functions created due to template instantiation) + # 1224: #warning directive + # 1881: argument must be a constant null pointer value + # (NULL in C++ is usually a literal 0) + QMAKE_CXXFLAGS += -Werror -ww177,1224,1881 $$WERROR + } + } else:gcc { + # GCC 4.6+ + # note: there was no GCC 3.6 and this assumes no one is crazy enough to compile Qt with GCC 2.7 + greaterThan(QT_GCC_MAJOR_VERSION, 4)|greaterThan(QT_GCC_MINOR_VERSION, 5) { + QMAKE_CXXFLAGS += -Werror -Wno-error=cpp $$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 + } + } +} diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 29c1e4a6619db28925956f814fdcf6ac1e179897..67db7b355564e2b7774173f3b77584e00962c35b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Intel Corporation ** Contact: http://www.qt-project.org/legal ** ** This file is part of the tools applications of the Qt Toolkit. @@ -244,6 +245,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "CFG_GCC_SYSROOT" ] = "yes"; dictionary[ "SLOG2" ] = "no"; dictionary[ "SYSTEM_PROXIES" ] = "no"; + dictionary[ "WERROR" ] = "auto"; //Only used when cross compiling. dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg"; @@ -891,6 +893,11 @@ void Configure::parseCmdLine() dictionary[ "SYSTEM_PROXIES" ] = "no"; } else if (configCmdLine.at(i) == "-system-proxies") { dictionary[ "SYSTEM_PROXIES" ] = "yes"; + } else if (configCmdLine.at(i) == "-warnings-are-errors" || + configCmdLine.at(i) == "-Werror") { + dictionary[ "WERROR" ] = "yes"; + } else if (configCmdLine.at(i) == "-no-warnings-are-errors") { + dictionary[ "WERROR" ] = "no"; } // Work around compiler nesting limitation @@ -1347,8 +1354,14 @@ void Configure::parseCmdLine() } // Allow tests for private classes to be compiled against internal builds - if (dictionary["BUILDDEV"] == "yes") - qtConfig += "private_tests"; + if (dictionary["BUILDDEV"] == "yes") { + qtConfig << "private_tests"; + if (dictionary["WERROR"] != "no") + qmakeConfig << "warnings_are_errors"; + } else { + if (dictionary["WERROR"] == "yes") + qmakeConfig << "warnings_are_errors"; + } if (dictionary["FORCE_ASSERTS"] == "yes") qtConfig += "force_asserts"; @@ -1718,6 +1731,8 @@ bool Configure::displayHelp() desc("SYSTEM_PROXIES", "yes", "-system-proxies", "Use system network proxies by default."); desc("SYSTEM_PROXIES", "no", "-no-system-proxies", "Do not use system network proxies by default.\n"); + desc("WERROR", "yes", "-warnings-are-errors", "Make warnings be treated as errors."); + desc("WERROR", "no", "-no-warnings-are-errors","Make warnings be treated normally."); #if !defined(EVAL) desc( "-qtnamespace <name>", "Wraps all Qt library code in 'namespace name {...}'.");