diff options
author | Yuhang Zhao <2546789017@qq.com> | 2020-11-02 12:36:14 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2020-11-02 20:06:22 +0800 |
commit | 4b694032dfe61dd9190170d15ee2edddbc9dfd7c (patch) | |
tree | 9e5d0917fd7e56d1324e0037bed13771230c73a5 /cmake/QtFlagHandlingHelpers.cmake | |
parent | 2b4a581f34854d9c0bb8d53626d929abd0661bd8 (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/QtFlagHandlingHelpers.cmake')
-rw-r--r-- | cmake/QtFlagHandlingHelpers.cmake | 21 |
1 files changed, 14 insertions, 7 deletions
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() |