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 <alexey.edelev@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Alexandru Croitor 2024-09-13 14:27:24 +02:00
parent a30c1bcd3c
commit 3f3d8604e6

View File

@ -77,6 +77,9 @@ function(qt_internal_add_simd_part target)
set(simd_flags_expanded "${${simd_flags_var_name}}") set(simd_flags_expanded "${${simd_flags_var_name}}")
endif() endif()
# 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. # If requested, don't pass the simd specific flags to excluded arches on apple platforms.
# Mostly important for universal / fat builds. # Mostly important for universal / fat builds.
get_target_property(osx_architectures ${target} OSX_ARCHITECTURES) get_target_property(osx_architectures ${target} OSX_ARCHITECTURES)
@ -88,6 +91,7 @@ function(qt_internal_add_simd_part target)
REPLACE "^(.+)$" "-Xarch_\\1;${simd_flags_expanded}" REPLACE "^(.+)$" "-Xarch_\\1;${simd_flags_expanded}"
OUTPUT_VARIABLE simd_flags_expanded) OUTPUT_VARIABLE simd_flags_expanded)
endif() endif()
endif()
# The manual loop is done on purpose. Check Gerrit comments for # The manual loop is done on purpose. Check Gerrit comments for
# 1b7008a3d784f3f266368f824cb43d473a301ba1. # 1b7008a3d784f3f266368f824cb43d473a301ba1.