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>
This commit is contained in:
parent
46db337975
commit
f9c850cc42
@ -598,6 +598,13 @@ QT_PATCH_VERSION = ${PROJECT_VERSION_PATCH}
|
||||
list(APPEND extra_statements "QT_MAC_SDK_VERSION = ${QT_MAC_SDK_VERSION}")
|
||||
list(APPEND extra_statements
|
||||
"QMAKE_MACOSX_DEPLOYMENT_TARGET = ${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
if (CMAKE_OSX_ARCHITECTURES)
|
||||
list(APPEND architectures "${CMAKE_OSX_ARCHITECTURES}")
|
||||
string (REPLACE ";" " " architectures "${architectures}")
|
||||
else()
|
||||
set(architectures "$$QT_ARCH")
|
||||
endif()
|
||||
list(APPEND extra_statements "QT_ARCHS = ${architectures}")
|
||||
endif()
|
||||
|
||||
list(APPEND extra_statements "QT_EDITION = Open Source")
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user