diff options
author | Albert Astals Cid <albert.astals.cid@kdab.com> | 2019-06-05 16:05:50 +0200 |
---|---|---|
committer | Albert Astals Cid <albert.astals.cid@kdab.com> | 2019-06-05 15:43:23 +0000 |
commit | f5a494f3c12451e0ea1a9ad82ad694a652be04e2 (patch) | |
tree | a55fdbe43c2e3bebe8456797da072902899f0572 /cmake/QtInternalTargets.cmake | |
parent | af074c2c0dc73db5e7e6f167965fad80e1549427 (diff) |
Introduce Platform*Internal targets
Link to them from add_qt_module/plugin/tool
This way we set the warnings_are_errors flags just once
and also non-qtbase modules get them
Change-Id: I2b65a81694aaebdd7c886249f217c11f79492bad
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtInternalTargets.cmake')
-rw-r--r-- | cmake/QtInternalTargets.cmake | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake new file mode 100644 index 0000000000..832e5d21b4 --- /dev/null +++ b/cmake/QtInternalTargets.cmake @@ -0,0 +1,69 @@ + +function(qt_internal_set_warnings_are_errors_flags target) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # Regular clang 3.0+ + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "3.0.0") + target_compile_options("${target}" INTERFACE -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations) + endif() + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + # using AppleClang + # Apple clang 4.0+ + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "4.0.0") + target_compile_options("${target}" INTERFACE -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations) + endif() + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # using GCC + target_compile_options("${target}" INTERFACE -Werror -Wno-error=cpp -Wno-error=deprecated-declarations) + + # 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 + target_compile_options("${target}" INTERFACE -Wno-error=strict-overflow) + + # GCC 7 includes -Wimplicit-fallthrough in -Wextra, but Qt is not yet free of implicit fallthroughs. + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0.0") + target_compile_options("${target}" INTERFACE -Wno-error=implicit-fallthrough) + endif() + + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0.0") + # GCC 9 introduced these but we are not clean for it. + target_compile_options("${target}" INTERFACE -Wno-error=deprecated-copy -Wno-error=redundant-move -Wno-error=init-list-lifetime) + endif() + + # Work-around for bug https://code.google.com/p/android/issues/detail?id=58135 + if (ANDROID) + target_compile_options("${target}" INTERFACE -Wno-error=literal-suffix) + endif() + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + # Intel CC 13.0 +, on Linux only + if (LINUX) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0.0") + # 177: function "entity" was declared but never referenced + # (too aggressive; ICC reports even for functions created due to template instantiation) + # 1224: #warning directive + # 1478: function "entity" (declared at line N) was declared deprecated + # 1786: function "entity" (declared at line N of "file") was declared deprecated ("message") + # 1881: argument must be a constant null pointer value + # (NULL in C++ is usually a literal 0) + target_compile_options("${target}" INTERFACE -Werror -ww177,1224,1478,1786,1881) + endif() + endif() + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # using Visual Studio C++ + target_compile_options("${target}" INTERFACE /WX) + endif() +endfunction() + +add_library(PlatformModuleInternal INTERFACE) +add_library(Qt::PlatformModuleInternal ALIAS PlatformModuleInternal) + +add_library(PlatformPluginInternal INTERFACE) +add_library(Qt::PlatformPluginInternal ALIAS PlatformPluginInternal) + +add_library(PlatformToolInternal INTERFACE) +add_library(Qt::PlatformToolInternal ALIAS PlatformToolInternal) + +if(WARNINGS_ARE_ERRORS) + qt_internal_set_warnings_are_errors_flags(PlatformModuleInternal) + qt_internal_set_warnings_are_errors_flags(PlatformPluginInternal) + qt_internal_set_warnings_are_errors_flags(PlatformToolInternal) +endif() |