From 3e13fd43df6208aca3c4d5e94a8aa9f0d255ff85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 3 Nov 2020 16:37:00 +0200 Subject: [PATCH] cmake: Always add -Wno-ignored-attributes for clang targeting windows This matches how it is in the qmake mkspec, silencing a lot of warnings - but contrary to when building with qmake, it's only applied when building Qt itself. For external projects built with cmake, the Qt headers are included with -isystem, which silences any warnings from those headers. Change-Id: I1a498d3c2715cb73e647668cb7226ceeffb7ff0b Reviewed-by: Alexandru Croitor --- cmake/QtInternalTargets.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake index a04e216943..108571e759 100644 --- a/cmake/QtInternalTargets.cmake +++ b/cmake/QtInternalTargets.cmake @@ -6,12 +6,6 @@ function(qt_internal_set_warnings_are_errors_flags target) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "3.0.0") list(APPEND flags -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations) endif() - if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - # Clang will otherwise show error about inline method conflicting with dllimport class attribute in tools - # (this was tested with Clang 10) - # error: 'QString::operator[]' redeclared inline; 'dllimport' attribute ignored [-Werror,-Wignored-attributes] - list(APPEND flags -Wno-ignored-attributes) - endif() elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") # using AppleClang # Apple clang 4.0+ @@ -110,6 +104,13 @@ if(FEATURE_largefile AND UNIX) INTERFACE "_LARGEFILE64_SOURCE;_LARGEFILE_SOURCE") endif() +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_SYSTEM_NAME STREQUAL "Windows") + # Clang will otherwise show error about inline method conflicting with dllimport class attribute in tools + # (this was tested with Clang 10) + # error: 'QString::operator[]' redeclared inline; 'dllimport' attribute ignored [-Werror,-Wignored-attributes] + target_compile_options(PlatformCommonInternal INTERFACE -Wno-ignored-attributes) +endif() + # We can't use the gold linker on android with the NDK, which is the default # linker. To build our own target we will use the lld linker. # TODO: Why not?