From 3f3d8604e6ed5b6854301f4a3c4799cfa256d8b0 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 13 Sep 2024 14:27:24 +0200 Subject: [PATCH] CMake: Don't process SIMD OSX_ARCHITECTURES on non-Apple platforms If a user accidentally passes 'CMAKE_OSX_ARCHITECTURES=x86_64;arm64' to configure on a Linux x86_64 platform, the build would fail when compiling qdrawhelper_avx2.cpp.o either due to an architecture mismatch, or due to not recognizing the -Xarch flag on older gcc compilers. Only add xarch flags to SIMD compilation on Apple platforms. Pick-to: 6.8 Change-Id: I322316979626b04cb0378f4dbf3cc26ec96183ac Reviewed-by: Alexey Edelev Reviewed-by: Marcus Tillmanns --- cmake/QtSimdHelpers.cmake | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cmake/QtSimdHelpers.cmake b/cmake/QtSimdHelpers.cmake index 1e77bf449f8..7dbe6b9f1b0 100644 --- a/cmake/QtSimdHelpers.cmake +++ b/cmake/QtSimdHelpers.cmake @@ -77,16 +77,20 @@ function(qt_internal_add_simd_part target) set(simd_flags_expanded "${${simd_flags_var_name}}") endif() - # If requested, don't pass the simd specific flags to excluded arches on apple platforms. - # Mostly important for universal / fat builds. - get_target_property(osx_architectures ${target} OSX_ARCHITECTURES) - if(simd_flags_expanded AND osx_architectures AND arg_EXCLUDE_OSX_ARCHITECTURES) - list(REMOVE_ITEM osx_architectures ${arg_EXCLUDE_OSX_ARCHITECTURES}) + # Only process OSX_ARCHITECTURES when targeting Apple platforms, otherwise it might fail + # non-Apple builds when CMAKE_OSX_ARCHITECTURES is accidentally passed to configure. + if(APPLE) + # If requested, don't pass the simd specific flags to excluded arches on apple platforms. + # Mostly important for universal / fat builds. + get_target_property(osx_architectures ${target} OSX_ARCHITECTURES) + if(simd_flags_expanded AND osx_architectures AND arg_EXCLUDE_OSX_ARCHITECTURES) + list(REMOVE_ITEM osx_architectures ${arg_EXCLUDE_OSX_ARCHITECTURES}) - # Assumes that simd_flags_expanded contains only one item on apple platforms. - list(TRANSFORM osx_architectures - REPLACE "^(.+)$" "-Xarch_\\1;${simd_flags_expanded}" - OUTPUT_VARIABLE simd_flags_expanded) + # Assumes that simd_flags_expanded contains only one item on apple platforms. + list(TRANSFORM osx_architectures + REPLACE "^(.+)$" "-Xarch_\\1;${simd_flags_expanded}" + OUTPUT_VARIABLE simd_flags_expanded) + endif() endif() # The manual loop is done on purpose. Check Gerrit comments for