1# 2# W A R N I N G 3# ------------- 4# 5# This file is not part of the Qt API. It exists purely as an 6# implementation detail. It may change from version to version 7# without notice, or even be removed. 8# 9# We mean it. 10# 11 12QMAKE_DIR_REPLACE_SANE += DESTDIR 13CONFIG -= debug_and_release_target 14 15DEFINES *= QT_NO_NARROWING_CONVERSIONS_IN_CONNECT 16 17qtConfig(c++11): CONFIG += c++11 strict_c++ 18qtConfig(c++14): CONFIG += c++14 19qtConfig(c++1z): CONFIG += c++1z 20qtConfig(c++2a): CONFIG += c++2a 21qtConfig(c99): CONFIG += c99 22qtConfig(c11): CONFIG += c11 23qtConfig(separate_debug_info): CONFIG += separate_debug_info 24qtConfig(stack-protector-strong): CONFIG += stack_protector_strong 25contains(TEMPLATE, .*lib) { 26 # module and plugins 27 unix:qtConfig(reduce_relocations): CONFIG += bsymbolic_functions 28} 29contains(TEMPLATE, .*lib)|contains(TEMPLATE, aux) { 30 !isEmpty(_QMAKE_SUPER_CACHE_): \ 31 rplbase = $$dirname(_QMAKE_SUPER_CACHE_)/[^/][^/]* 32 else: \ 33 rplbase = $$MODULE_BASE_OUTDIR 34 host_build { 35 qqt_libdir = \$\$\$\$[QT_HOST_LIBS] 36 qt_libdir = $$[QT_HOST_LIBS] 37 } else { 38 qqt_libdir = \$\$\$\$[QT_INSTALL_LIBS] 39 qt_libdir = $$[QT_INSTALL_LIBS] 40 } 41 contains(QMAKE_DEFAULT_LIBDIRS, $$qt_libdir) { 42 lib_replace0.match = $$rplbase/lib/ 43 lib_replace0.replace = $$qqt_libdir/ 44 lib_replace0.CONFIG = path 45 QMAKE_PRL_INSTALL_REPLACE += lib_replace0 46 lib_replace.match = "[^ ']*$$rplbase/lib" 47 lib_replace.replace = 48 } else { 49 lib_replace.match = $$rplbase/lib 50 lib_replace.replace = $$qqt_libdir 51 } 52 lib_replace.CONFIG = path 53 QMAKE_PRL_INSTALL_REPLACE += lib_replace 54 !equals(qt_libdir, $$rplbase/lib) { 55 qtlibdir_replace.match = $$qt_libdir 56 qtlibdir_replace.replace = $$qqt_libdir 57 qtlibdir_replace.CONFIG = path 58 QMAKE_PRL_INSTALL_REPLACE += qtlibdir_replace 59 } 60} 61contains(TEMPLATE, .*lib)|darwin { 62 if(!host_build|!cross_compile):qtConfig(reduce_exports): CONFIG += hide_symbols 63} 64 65# Apple deprecated the entire OpenGL API in favor of Metal, which 66# we are aware of, so silence the deprecation warnings in code. 67# This does not apply to user-code, which will need to silence 68# their own warnings if they use the deprecated APIs explicitly. 69macos: DEFINES += GL_SILENCE_DEPRECATION 70uikit: DEFINES += GLES_SILENCE_DEPRECATION 71 72# The remainder of this file must not apply to host tools/libraries, 73# as the host compiler's version and capabilities are not checked. 74host_build:cross_compile: return() 75 76# Extra warnings for Qt non-example code, to ensure cleanliness of the sources. 77# The block below may turn these warnings into errors for some Qt targets. 78# -Wdate-time: warn if we use __DATE__ or __TIME__ (we want to be able to reproduce the exact same binary) 79# -Wvla: use of variable-length arrays (an extension to C++) 80clang { 81 clang_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION} 82 apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION} 83 versionAtLeast(clang_ver, 3.5): \ 84 QMAKE_CXXFLAGS_WARN_ON += -Wdate-time 85 86 versionAtLeast(clang_ver, 3.6)|versionAtLeast(apple_ver, 6.3): \ 87 QMAKE_CXXFLAGS_WARN_ON += -Winconsistent-missing-override 88 89 darwin { 90 QMAKE_CXXFLAGS_WARN_ON += \ 91 -Wobjc-interface-ivars \ 92 -Wobjc-method-access \ 93 -Wobjc-multiple-method-names 94 95 # Clang/LLVM 5.0 and Xcode 9.0 introduced unguarded availability warnings. 96 # The same construct has been a hard error in Swift from the very beginning. 97 versionAtLeast(clang_ver, 5.0)|versionAtLeast(apple_ver, 9.0): \ 98 QMAKE_CXXFLAGS_WARN_ON += \ 99 -Werror=unguarded-availability \ 100 -Werror=unguarded-availability-new \ 101 -Werror=unsupported-availability-guard 102 } 103} else: gcc:!intel_icc { 104 QMAKE_CXXFLAGS_WARN_ON += -Wvla 105 # GCC 5 fixed -Wmissing-field-initializers for when there are no initializers 106 lessThan(QT_GCC_MAJOR_VERSION, 5): QMAKE_CXXFLAGS_WARN_ON += -Wno-missing-field-initializers 107 # GCC 5 introduced -Wdate-time 108 greaterThan(QT_GCC_MAJOR_VERSION, 4): QMAKE_CXXFLAGS_WARN_ON += -Wdate-time 109 # GCC 6 introduced these 110 greaterThan(QT_GCC_MAJOR_VERSION, 5): QMAKE_CXXFLAGS_WARN_ON += -Wshift-overflow=2 -Wduplicated-cond 111 # GCC 7 has a lot of false positives relating to this, so disable completely 112 greaterThan(QT_GCC_MAJOR_VERSION, 6): QMAKE_CXXFLAGS_WARN_ON += -Wno-stringop-overflow 113 # GCC 9 introduced -Wformat-overflow in -Wall, but it is buggy: 114 greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-format-overflow 115} 116 117warnings_are_errors:warning_clean { 118 # If the module declares that it has does its clean-up of warnings, enable -Werror. 119 # This setting is compiler-dependent anyway because it depends on the version of the 120 # compiler. 121 clang { 122 # Apple clang 4.0-4.2,5.0-5.1,6.0-6.4,7.0-7.3,8.0-8.3,9.0-9.2 123 # Regular clang 3.x-7.0 124 apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION} 125 reg_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION} 126 contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]|8\\.[0123]|9\\.[012]")|contains(reg_ver, "[345]\\.|[67]\\.0") { 127 QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR 128 } 129 } else:intel_icc:linux { 130 # Intel CC 13.0 - 18.0, on Linux only 131 ver = $${QT_ICC_MAJOR_VERSION}.$${QT_ICC_MINOR_VERSION} 132 linux:contains(ver, "(1[345678]\\.|19\\.0)") { 133 # 177: function "entity" was declared but never referenced 134 # (too aggressive; ICC reports even for functions created due to template instantiation) 135 # 1224: #warning directive 136 # 1478: function "entity" (declared at line N) was declared deprecated 137 # 1786: function "entity" (declared at line N of "file") was declared deprecated ("message") 138 # 1881: argument must be a constant null pointer value 139 # (NULL in C++ is usually a literal 0) 140 QMAKE_CXXFLAGS_WARN_ON += -Werror -ww177,1224,1478,1786,1881 $$WERROR 141 } 142 } else:gcc:!clang:!intel_icc:!rim_qcc { 143 # GCC 4.6-4.9, 5.x, ... 144 ver = $${QT_GCC_MAJOR_VERSION}.$${QT_GCC_MINOR_VERSION} 145 contains(ver, "(4\\.[6789]|[5-9]\\..)") { 146 QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=cpp -Wno-error=deprecated-declarations $$WERROR 147 148 # GCC prints this bogus warning, after it has inlined a lot of code 149 # error: assuming signed overflow does not occur when assuming that (X + c) < X is always false 150 QMAKE_CXXFLAGS_WARN_ON += -Wno-error=strict-overflow 151 152 # Work-around for bug https://code.google.com/p/android/issues/detail?id=58135 153 android: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=literal-suffix 154 } 155 } else:msvc:!intel_icl { 156 # enable for MSVC 2015, MSVC 2017 157 contains(MSVC_VER, "1[45].0"): QMAKE_CXXFLAGS_WARN_ON += -WX 158 } 159 unset(ver) 160} 161 162