From a20a6ae7ea4f8dad324308ee6e5a41f0318cf29b Mon Sep 17 00:00:00 2001 From: Yuhang Zhao Date: Sat, 7 Oct 2023 14:17:30 +0800 Subject: [PATCH] cmake: simplify exceptions handling code A little code simplification. And we can enable exception handling explicitly for GCC/Clang by adding "-fexceptions", it was missing in the old code, add it as well. [ChangeLog] [Build System] Qt explicitly pass -fexceptions now on non-MSVC toolchains, if exception handling is not disabled in CMake configure. Change-Id: Id9d61d3ee8b7d490f4a743e34e8be321af080be0 Reviewed-by: Alexandru Croitor Reviewed-by: Joerg Bornemann --- cmake/QtFlagHandlingHelpers.cmake | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake index 168b67463b..0bea41523a 100644 --- a/cmake/QtFlagHandlingHelpers.cmake +++ b/cmake/QtFlagHandlingHelpers.cmake @@ -256,19 +256,15 @@ function(qt_internal_set_exceptions_flags target exceptions_on) # this hack since some unknown MSVC version. set(_flag ${_flag} "/d2FH4") endif() + else() + set(_flag "-fexceptions") endif() else() set(_defs "QT_NO_EXCEPTIONS") - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + if(MSVC) set(_flag "/EHs-c-" "/wd4530" "/wd4577") - elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|AppleClang|InteLLLVM") + else() set(_flag "-fno-exceptions") - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if (MSVC) - set(_flag "/EHs-c-" "/wd4530" "/wd4577") - else() - set(_flag "-fno-exceptions") - endif() endif() endif()