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 <alexandru.croitor@qt.io>
bb10
Martin Storsjö 2020-11-03 16:37:00 +02:00
parent 6f8df4dac0
commit 3e13fd43df
1 changed files with 7 additions and 6 deletions

View File

@ -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?