summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-10-15 11:10:08 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-11-12 17:30:35 +0000
commitf00068561287e64c8c664ee1af3feff08b22b669 (patch)
treeb05004aeeda2cdaa63b3169e40903f85eddae229 /cmake
parentf2c57e83ab21f5f5ad01f309643821a8851493b5 (diff)
Add support for skipping warnings are errors
Unfortunately not all repositories are marked as warning_clean in their .qmake.conf files. For instance qtconnectivity and qttools are not warning clean. Therefore we need to skip warnings_are_errors flags on all targets created in that repository. Add support for skipping the warnings are errors flags, by setting a QT_SKIP_WARNINGS_ARE_ERRORS property on a target, and use that within a generator expression with all the accumulated flags. To mimic behavior of qmake, and set the property on all targets created by add_qt_module, add_qt_plugin, etc, one simply needs to set the QT_REPO_NOT_WARNINGS_CLEAN variable in the repo project CMakeLists.txt. Change-Id: Ib5a487af6601ae1519a0988a89f8083f94f92267 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake14
-rw-r--r--cmake/QtInternalTargets.cmake22
2 files changed, 27 insertions, 9 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 31a0e3f7c9..472f9397dc 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -1303,6 +1303,16 @@ function(qt_internal_set_no_exceptions_flags target)
endif()
endfunction()
+function(qt_skip_warnings_are_errors target)
+ set_target_properties("${target}" PROPERTIES QT_SKIP_WARNINGS_ARE_ERRORS ON)
+endfunction()
+
+function(qt_skip_warnings_are_errors_when_repo_unclean target)
+ if(QT_REPO_NOT_WARNINGS_CLEAN)
+ qt_skip_warnings_are_errors("${target}")
+ endif()
+endfunction()
+
# This is the main entry function for creating a Qt module, that typically
# consists of a library, public header files, private header files and configurable
# features.
@@ -1343,6 +1353,7 @@ function(add_qt_module target)
qt_android_apply_arch_suffix("${target}")
endif()
qt_internal_add_target_aliases("${target}")
+ qt_skip_warnings_are_errors_when_repo_unclean("${target}")
# Add _private target to link against the private headers:
if(NOT ${arg_NO_PRIVATE_MODULE})
@@ -1834,6 +1845,7 @@ function(add_qt_plugin target)
)
endif()
qt_internal_add_target_aliases("${target}")
+ qt_skip_warnings_are_errors_when_repo_unclean("${target}")
set_target_properties("${target}" PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${output_directory}"
@@ -2310,6 +2322,7 @@ function(add_qt_executable name)
endif()
qt_autogen_tools_initial_setup(${name})
+ qt_skip_warnings_are_errors_when_repo_unclean("${target}")
set(extra_libraries "")
if(NOT arg_BOOTSTRAP AND NOT arg_NO_QT)
@@ -2672,6 +2685,7 @@ function(add_cmake_library target)
if (ANDROID)
qt_android_apply_arch_suffix("${target}")
endif()
+ qt_skip_warnings_are_errors_when_repo_unclean("${target}")
if (arg_INSTALL_DIRECTORY)
set(install_arguments
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake
index ad8ded29cf..2db065fbf5 100644
--- a/cmake/QtInternalTargets.cmake
+++ b/cmake/QtInternalTargets.cmake
@@ -1,37 +1,38 @@
function(qt_internal_set_warnings_are_errors_flags target)
+ set(flags "")
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)
+ list(APPEND flags -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" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL "9.2")
- target_compile_options("${target}" INTERFACE -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations)
+ list(APPEND flags -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)
+ list(APPEND flags -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)
+ list(APPEND flags -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)
+ list(APPEND flags -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)
+ list(APPEND flags -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)
+ list(APPEND flags -Wno-error=literal-suffix)
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# Intel CC 13.0 +, on Linux only
@@ -44,7 +45,7 @@ function(qt_internal_set_warnings_are_errors_flags target)
# 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)
+ list(APPEND flags -Werror -ww177,1224,1478,1786,1881)
endif()
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
@@ -52,9 +53,12 @@ function(qt_internal_set_warnings_are_errors_flags target)
# MSVC 2012, 2013, 2015.
# Respectively MSVC_VERRSIONs are: 1700-1799, 1800-1899, 1900-1909.
if(MSVC_VERSION GREATER_EQUAL 1700 AND MSVC_VERSION LESS_EQUAL 1909)
- target_compile_options("${target}" INTERFACE /WX)
+ list(APPEND flags /WX)
endif()
endif()
+ set(add_flags "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_SKIP_WARNINGS_ARE_ERRORS>>>")
+ set(flags_generator_expression "$<${add_flags}:${flags}>")
+ target_compile_options("${target}" INTERFACE "${flags_generator_expression}")
endfunction()
add_library(PlatformCommonInternal INTERFACE)