From c571cb71a704e95ff1ace4f4a8b5044fdf9c7656 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 28 Apr 2020 17:41:20 +0200 Subject: [PATCH] CMake: Fix 32 bit Qt builds like our MinGW config in Coin Enable sse2 and fpmath for modules when appropriate, the logic is a port of the code in mkspecs/features/qt_module.prf. Fix qdrawhelper.cpp to always be compiled when using GCC with a special case. pro2cmake.py failed to handle the source subtraction correctly. Fixes: QTBUG-83791 Task-number: QTBUG-75578 Change-Id: Ibe32a250b266d580ad21f6c55f09fd03a14ceb82 Reviewed-by: Simon Hausmann --- cmake/QtInternalTargets.cmake | 49 +++++++++++++++++++++++++++++++++++ src/gui/CMakeLists.txt | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake index 29d89f1688..16db6e4bf0 100644 --- a/cmake/QtInternalTargets.cmake +++ b/cmake/QtInternalTargets.cmake @@ -148,3 +148,52 @@ if (MSVC) $<$:-OPT:REF> ) endif() + +function(qt_get_implicit_sse2_genex_condition out_var) + set(is_shared_lib "$,SHARED_LIBRARY>") + set(is_static_lib "$,STATIC_LIBRARY>") + set(is_static_qt_build "$>") + set(is_staitc_lib_during_static_qt_build "$") + set(enable_sse2_condition "$") + set(${out_var} "${enable_sse2_condition}" PARENT_SCOPE) +endfunction() + +function(qt_auto_detect_implicit_sse2) + # sse2 configuration adjustment in qt_module.prf + # If the compiler supports SSE2, enable it unconditionally in all of Qt shared libraries + # (and only the libraries). This is not expected to be a problem because: + # - on Windows, sharing of libraries is uncommon + # - on Mac OS X, all x86 CPUs already have SSE2 support (we won't even reach here) + # - on Linux, the dynamic loader can find the libraries on LIBDIR/sse2/ + # The last guarantee does not apply to executables and plugins, so we can't enable for them. + set(__implicit_sse2_for_qt_modules_enabled FALSE PARENT_SCOPE) + if(TEST_subarch_sse2 AND NOT TEST_arch_${TEST_architecture_arch}_subarch_sse2) + qt_get_implicit_sse2_genex_condition(enable_sse2_condition) + set(enable_sse2_genex "$<${enable_sse2_condition}:${QT_CFLAGS_SSE2}>") + target_compile_options(PlatformModuleInternal INTERFACE ${enable_sse2_genex}) + set(__implicit_sse2_for_qt_modules_enabled TRUE PARENT_SCOPE) + endif() +endfunction() +qt_auto_detect_implicit_sse2() + +function(qt_auto_detect_fpmath) + # fpmath configuration adjustment in qt_module.prf + set(fpmath_supported FALSE) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "3.4") + set(fpmath_supported TRUE) + endif() + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "5.1") + set(fpmath_supported TRUE) + endif() + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(fpmath_supported TRUE) + endif() + if(fpmath_supported AND TEST_architecture_arch STREQUAL "i386" AND __implicit_sse2_for_qt_modules_enabled) + qt_get_implicit_sse2_genex_condition(enable_sse2_condition) + set(enable_fpmath_genex "$<${enable_sse2_condition}:-mfpmath=sse>") + target_compile_options(PlatformModuleInternal INTERFACE ${enable_fpmath_genex}) + endif() +endfunction() +qt_auto_detect_fpmath() diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index f12c9ff5c8..686574700a 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -767,7 +767,7 @@ qt_extend_target(Gui CONDITION IOS OR MACOS ${FWMetal} ) -qt_extend_target(Gui CONDITION NOT GCC OR NOT QT_COMPILER_VERSION_MAJOR STREQUAL 5 +qt_extend_target(Gui # special case CONDITION NOT GCC OR NOT QT_COMPILER_VERSION_MAJOR STREQUAL 5 # source subtraction gone wrong SOURCES painting/qdrawhelper.cpp NO_PCH_SOURCES