summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorYuhang Zhao <2546789017@qq.com>2020-11-02 12:36:14 +0800
committerYuhang Zhao <2546789017@qq.com>2020-11-02 20:06:22 +0800
commit4b694032dfe61dd9190170d15ee2edddbc9dfd7c (patch)
tree9e5d0917fd7e56d1324e0037bed13771230c73a5 /cmake
parent2b4a581f34854d9c0bb8d53626d929abd0661bd8 (diff)
Improve clang-cl support for Qt6
1. clang-cl doesn't support "-fno-exceptions", it uses msvc's parameter. 2. some parameters supported by msvc are not supported by clang-cl and they are causing huge warning message flood, don't add them. 3. use correct optimize parameter for clang-cl. Change-Id: Idbadf139127143c5fa6c49068588cb26f47da7a2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtCompilerOptimization.cmake5
-rw-r--r--cmake/QtFlagHandlingHelpers.cmake21
-rw-r--r--cmake/QtInternalTargets.cmake10
3 files changed, 26 insertions, 10 deletions
diff --git a/cmake/QtCompilerOptimization.cmake b/cmake/QtCompilerOptimization.cmake
index 2e98dc31c2..333cbf3f15 100644
--- a/cmake/QtCompilerOptimization.cmake
+++ b/cmake/QtCompilerOptimization.cmake
@@ -158,6 +158,11 @@ if(MSVC)
set(QT_CFLAGS_OPTIMIZE_DEBUG "-Od")
set(QT_CFLAGS_OPTIMIZE_SIZE "-O1")
set(QT_CFLAGS_OPTIMIZE_VALID_VALUES "/O2" "/O1" "/Od" "/Ob0" "/Ob1" "/Ob2" "/O0" "-O0")
+
+ if(CLANG)
+ set(QT_CFLAGS_OPTIMIZE_FULL "/clang:-O3")
+ set(QT_CFLAGS_OPTIMIZE_SIZE "/clang:-Oz")
+ endif()
endif()
# Android Clang
diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake
index 2b6430a229..b9835a3639 100644
--- a/cmake/QtFlagHandlingHelpers.cmake
+++ b/cmake/QtFlagHandlingHelpers.cmake
@@ -92,7 +92,7 @@ function(qt_internal_apply_gc_binaries target visibility)
message(FATAL_ERROR "Visibitily setting must be one of PRIVATE, INTERFACE or PUBLIC.")
endif()
- if ((GCC OR CLANG) AND NOT EMSCRIPTEN AND NOT UIKIT)
+ if ((GCC OR CLANG) AND NOT EMSCRIPTEN AND NOT UIKIT AND NOT MSVC)
if(APPLE)
set(gc_sections_flag "-Wl,-dead_strip")
elseif(SOLARIS)
@@ -105,7 +105,7 @@ function(qt_internal_apply_gc_binaries target visibility)
target_link_options("${target}" ${visibility} "${gc_sections_flag}")
endif()
- if((GCC OR CLANG OR ICC) AND NOT EMSCRIPTEN AND NOT UIKIT)
+ if((GCC OR CLANG OR ICC) AND NOT EMSCRIPTEN AND NOT UIKIT AND NOT MSVC)
set(split_sections_flags "-ffunction-sections" "-fdata-sections")
endif()
if(split_sections_flags)
@@ -149,15 +149,22 @@ endfunction()
function(qt_internal_set_no_exceptions_flags target)
target_compile_definitions("${target}" PRIVATE "QT_NO_EXCEPTIONS")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
- target_compile_options("${target}" PRIVATE "/wd4530" "/wd4577")
+ set(_flag "/wd4530" "/wd4577")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- target_compile_options("${target}" PRIVATE "-fno-exceptions")
+ set(_flag "-fno-exceptions")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
- target_compile_options("${target}" PRIVATE "-fno-exceptions")
+ set(_flag "-fno-exceptions")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- target_compile_options("${target}" PRIVATE "-fno-exceptions")
+ if (MSVC)
+ set(_flag "/wd4530" "/wd4577")
+ else()
+ set(_flag "-fno-exceptions")
+ endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
- target_compile_options("${target}" PRIVATE "-fno-exceptions")
+ set(_flag "-fno-exceptions")
+ endif()
+ if (_flag)
+ target_compile_options("${target}" PRIVATE ${_flag})
endif()
endfunction()
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake
index 91a75983ea..cdaa91ffcb 100644
--- a/cmake/QtInternalTargets.cmake
+++ b/cmake/QtInternalTargets.cmake
@@ -178,15 +178,19 @@ if (MSVC)
if (MSVC_VERSION GREATER_EQUAL 1899)
target_compile_options(PlatformCommonInternal INTERFACE
-Zc:strictStrings
- -Zc:throwingNew
)
+ if (NOT CLANG)
+ target_compile_options(PlatformCommonInternal INTERFACE
+ -Zc:throwingNew
+ )
+ endif()
endif()
- if (MSVC_VERSION GREATER_EQUAL 1909)
+ if (MSVC_VERSION GREATER_EQUAL 1909 AND NOT CLANG)
target_compile_options(PlatformCommonInternal INTERFACE
-Zc:referenceBinding
)
endif()
- if (MSVC_VERSION GREATER_EQUAL 1919)
+ if (MSVC_VERSION GREATER_EQUAL 1919 AND NOT CLANG)
target_compile_options(PlatformCommonInternal INTERFACE
-Zc:externConstexpr
)