1#Turn on compilers warnings.
2unix {
3    *g++*{
4        QMAKE_CXXFLAGS += \
5            # Key -isystem disable checking errors in system headers.
6            -isystem "$${OUT_PWD}/$${MOC_DIR}" \
7            -isystem "$${OUT_PWD}/$${RCC_DIR}" \
8            $$GCC_DEBUG_CXXFLAGS # See common.pri for more details.
9
10        checkWarnings{ # For enable run qmake with CONFIG+=checkWarnings
11            QMAKE_CXXFLAGS += -Werror
12        }
13
14        win32:equals(QT_MAJOR_VERSION, 5):equals(QT_MINOR_VERSION, 6) {
15            QMAKE_CXXFLAGS += \
16                -Wno-array-bounds
17        }
18
19        noAddressSanitizer{ # For enable run qmake with CONFIG+=noAddressSanitizer
20            # do nothing
21        } else {
22            CONFIG(debug, debug|release){
23                # Debug mode
24                #gcc’s 4.8.0 Address Sanitizer
25                #http://blog.qt.digia.com/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt/
26                QMAKE_CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer
27                QMAKE_CFLAGS += -fsanitize=address -fno-omit-frame-pointer
28                QMAKE_LFLAGS += -fsanitize=address
29            }
30        }
31
32        gccUbsan{ # For enable run qmake with CONFIG+=gccUbsan
33            CONFIG(debug, debug|release){
34                # Debug mode
35                #gcc’s 4.9.0 Undefined Behavior Sanitizer (ubsan)
36                QMAKE_CXXFLAGS += -fsanitize=undefined
37                QMAKE_CFLAGS += -fsanitize=undefined
38                QMAKE_LFLAGS += -fsanitize=undefined
39            }
40        }
41    }
42
43    *clang*{
44        QMAKE_CXXFLAGS += \
45            # Key -isystem disable checking errors in system headers.
46            -isystem "$${OUT_PWD}/$${MOC_DIR}" \
47            -isystem "$${OUT_PWD}/$${RCC_DIR}" \
48            $$CLANG_DEBUG_CXXFLAGS \# See common.pri for more details.
49            -Wno-gnu-zero-variadic-macro-arguments\ # See macros qCCritical
50
51        checkWarnings{ # For enable run qmake with CONFIG+=checkWarnings
52            QMAKE_CXXFLAGS += -Werror
53        }
54
55        # -isystem key works only for headers. In some cases it's not enough. But we can't delete this warnings and
56        # want them in global list. Compromise decision delete them from local list.
57        QMAKE_CXXFLAGS -= \
58            -Wundefined-reinterpret-cast \
59            -Wmissing-prototypes # rcc folder
60    }
61
62    *-icc-*{
63        QMAKE_CXXFLAGS += \
64            -isystem "$${OUT_PWD}/$${MOC_DIR}" \
65            -isystem "$${OUT_PWD}/$${RCC_DIR}" \
66            $$ICC_DEBUG_CXXFLAGS
67
68        checkWarnings{ # For enable run qmake with CONFIG+=checkWarnings
69            QMAKE_CXXFLAGS += -Werror
70        }
71    }
72} else { # Windows
73    *g++*{
74        QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See common.pri for more details.
75
76        checkWarnings{ # For enable run qmake with CONFIG+=checkWarnings
77            QMAKE_CXXFLAGS += -Werror
78        }
79    }
80
81    *msvc*{
82        QMAKE_CXXFLAGS += $$MSVC_DEBUG_CXXFLAGS # See common.pri for more details.
83
84        checkWarnings{ # For enable run qmake with CONFIG+=checkWarnings
85            QMAKE_CXXFLAGS += -WX
86        }
87    }
88}
89