summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-04-28 17:41:20 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-05-01 19:11:17 +0200
commitc571cb71a704e95ff1ace4f4a8b5044fdf9c7656 (patch)
tree0f3fe7a366e942f684eeecd57172857aeae43211 /cmake
parentbe04ee67deb2955f0e1f5915fb17c5411377f7d4 (diff)
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 <hausmann@gmail.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtInternalTargets.cmake49
1 files changed, 49 insertions, 0 deletions
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)
$<$<CONFIG:RelWithDebInfo>:-OPT:REF>
)
endif()
+
+function(qt_get_implicit_sse2_genex_condition out_var)
+ set(is_shared_lib "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>")
+ set(is_static_lib "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,STATIC_LIBRARY>")
+ set(is_static_qt_build "$<NOT:$<BOOL:${QT_BUILD_SHARED_LIBS}>>")
+ set(is_staitc_lib_during_static_qt_build "$<AND:${is_static_qt_build},${is_static_lib}>")
+ set(enable_sse2_condition "$<OR:${is_shared_lib},${is_staitc_lib_during_static_qt_build}>")
+ 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()