Skip to content

Commit

Permalink
cmake: Always add -Wno-ignored-attributes for clang targeting windows
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mstorsjo committed Nov 4, 2020
1 parent 6f8df4d commit 3e13fd4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cmake/QtInternalTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down Expand Up @@ -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?
Expand Down

0 comments on commit 3e13fd4

Please sign in to comment.