summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/mac/default_post.prf
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-05-21 12:01:26 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-05-21 17:45:28 +0000
commitf9c850cc42a5591c096e1b0d547efb93ad18f1f1 (patch)
treeb5dc8f29c6dda26c5ef2eb43232e07958a12d6a7 /mkspecs/features/mac/default_post.prf
parent46db3379750d8b6ef99184cb03f89f4a48b3427a (diff)
qmake: Pick default architecture on macOS based on uname
When dealing with a universal build of Qt, we would end up using the QT_ARCH as the architecture for user projects, but this architecture is always the primary one that Qt was configured with. Instead of relying on QT_ARCH, we start writing QT_ARCHS (plural) to qconfig.pri, based on CMAKE_OSX_ARCHITECTURES, and then use that to initialize QMAKE_APPLE_DEVICE_ARCHS. We then resolve the active arch using uname -m, matching what CMake does. We still feed all the available architectures to the Makefile or Xcode project, so that the user can build for any of the available architectures without needing a reconfigure. Fixes: QTBUG-93760 Change-Id: I0d338241ba4d944ca36d85371e9c4df7dbc4f269 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'mkspecs/features/mac/default_post.prf')
-rw-r--r--mkspecs/features/mac/default_post.prf18
1 files changed, 12 insertions, 6 deletions
diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
index 0fcb1a55b9..18a451aaf5 100644
--- a/mkspecs/features/mac/default_post.prf
+++ b/mkspecs/features/mac/default_post.prf
@@ -95,10 +95,11 @@ app_extension_api_only {
QMAKE_LFLAGS += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
}
-# Non-universal builds do not set QMAKE_APPLE_DEVICE_ARCHS,
-# so we pick it up from what the arch test resolved instead.
+# Pick up available architectures from what Qt was built with,
+# so that our Makefile or Xcode project is set up to build for
+# any of the available architectures.
isEmpty(QMAKE_APPLE_DEVICE_ARCHS): \
- QMAKE_APPLE_DEVICE_ARCHS = $$QT_ARCH
+ QMAKE_APPLE_DEVICE_ARCHS = $$QT_ARCHS
macx-xcode {
qmake_pkginfo_typeinfo.name = QMAKE_PKGINFO_TYPEINFO
@@ -157,10 +158,15 @@ macx-xcode {
single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
- ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS))
- ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ACTIVE_ARCHS), $(EXPORT_ACTIVE_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch))
+ macos: ACTIVE_ARCH = $$system("uname -m")
- QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCHS ARCH_ARGS
+ ARCHS = $(filter $(EXPORT_VALID_ARCHS), \
+ $(if $(ARCHS), $(ARCHS), \
+ $(if $(EXPORT_ACTIVE_ARCH), $(EXPORT_ACTIVE_ARCH), \
+ $(EXPORT_VALID_ARCHS))))
+ ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ARCHS), $(EXPORT_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch))
+
+ QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCH ARCHS ARCH_ARGS
arch_flags = $(EXPORT_ARCH_ARGS)