diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake index b95257cc69e..89d0f893e9b 100644 --- a/cmake/QtInternalTargets.cmake +++ b/cmake/QtInternalTargets.cmake @@ -262,6 +262,13 @@ endif() # Taken from mkspecs/common/msvc-version.conf and mkspecs/common/msvc-desktop.conf if (MSVC AND NOT CLANG) if (MSVC_VERSION GREATER_EQUAL 1799) + set_target_properties(PlatformCommonInternal PROPERTIES _qt_cpp_compiler_frontend_variant + "${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}") + + # Protect against adding these flags when building qtbase with MSVC, and qtwebengine using + # clang-cl. + set(is_not_clang_cl_start "$<$,Clang>>:") + set(is_not_clang_cl_end ">") target_compile_options(PlatformCommonInternal INTERFACE -FS -Zc:rvalueCast @@ -271,18 +278,18 @@ if (MSVC AND NOT CLANG) if (MSVC_VERSION GREATER_EQUAL 1899) target_compile_options(PlatformCommonInternal INTERFACE -Zc:strictStrings - -Zc:throwingNew + "${is_not_clang_cl_start}-Zc:throwingNew${is_not_clang_cl_end}" ) endif() if (MSVC_VERSION GREATER_EQUAL 1909) # MSVC 2017 target_compile_options(PlatformCommonInternal INTERFACE - -Zc:referenceBinding + "${is_not_clang_cl_start}-Zc:referenceBinding${is_not_clang_cl_end}" -Zc:ternary ) endif() if (MSVC_VERSION GREATER_EQUAL 1919) # MSVC 2019 target_compile_options(PlatformCommonInternal INTERFACE - -Zc:externConstexpr + "${is_not_clang_cl_start}-Zc:externConstexpr${is_not_clang_cl_end}" #-Zc:lambda # Buggy. TODO: Enable again when stable enough. #-Zc:preprocessor # breaks build due to bug in default Windows SDK 10.0.19041 )