diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-20 17:16:04 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-20 18:12:26 +0200 |
commit | bd4726fa5d553b8e84ff15f7d24ff6620beb32af (patch) | |
tree | a61467cf819acc979c4d70011c3eb83afdfa241e /cmake/QtFeature.cmake | |
parent | 5e0129f63cbd45767342c43135f6061750511e33 (diff) |
CMake: Pass CMAKE_OSX_ARCHITECTURES to try_compile on macOS
There was an inconsistency where configuring qtbase on Apple Silicon
with the following command line produced different results rom the
second variant.
$ cmake ../qtbase -DCMAKE_OSX_ARCHITECTURES=arm64
vs
$ CMAKE_OSX_ARCHITECTURES=arm64 cmake ../qtbase
That happened because the CMAKE_OSX_ARCHITECTURES variables was not
passed to project-based try_compile calls. This resulted in compile
tests like SIMD avx to succeeded on Apple silicon, which shouldn't.
To address that, always pass the architecture on macOS if it's
specified.
Change-Id: Ia12e86230cc6e5e11f387e3cbb273d90646ef2e3
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/QtFeature.cmake')
-rw-r--r-- | cmake/QtFeature.cmake | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 1ac23200c8..5058a7f86b 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -813,16 +813,18 @@ function(qt_get_platform_try_compile_vars out_var) endforeach() # Pass darwin specific options. - if(UIKIT) - if(CMAKE_OSX_ARCHITECTURES) - list(GET CMAKE_OSX_ARCHITECTURES 0 osx_first_arch) + # The architectures need to be passed explicitly to project-based try_compile calls even on + # macOS, so that arm64 compilation works on Apple silicon. + if(CMAKE_OSX_ARCHITECTURES) + list(GET CMAKE_OSX_ARCHITECTURES 0 osx_first_arch) - # Do what qmake does, aka when doing a simulator_and_device build, build the - # target architecture test only with the first given architecture, which should be the - # device architecture, aka some variation of "arm" (armv7, arm64). - list(APPEND flags_cmd_line "-DCMAKE_OSX_ARCHITECTURES:STRING=${osx_first_arch}") - endif() - # Also specify the sysroot, but only if not doing a simulator_and_device build. + # Do what qmake does, aka when doing a simulator_and_device build, build the + # target architecture test only with the first given architecture, which should be the + # device architecture, aka some variation of "arm" (armv7, arm64). + list(APPEND flags_cmd_line "-DCMAKE_OSX_ARCHITECTURES:STRING=${osx_first_arch}") + endif() + if(UIKIT) + # Specify the sysroot, but only if not doing a simulator_and_device build. # So keep the sysroot empty for simulator_and_device builds. if(QT_UIKIT_SDK) list(APPEND flags_cmd_line "-DCMAKE_OSX_SYSROOT:STRING=${QT_UIKIT_SDK}") |