如何在 qmake 中检测目标 iOS 架构?
How to detect target iOS architecture in qmake?
我有一个支持以下 ABI 的 Qt 版本(Qt Creator → Preferences → Build & 运行 / Qt Versions):
- arm-macos-generic-mach_o-32bit
- arm-macos-generic-mach_o-64bit
- x86-macos-generic-mach_o-32bit
- x86-macos-generic-mach_o-64bit
因此,将此 Qt 版本与不同的编译器结合在一个 Qt 套件中,我可以为所有提到的架构构建库。
同时mkspecs/qconfig.pri
包含:
host_build {
QT_ARCH = x86_64
QT_TARGET_ARCH = arm
} else {
QT_ARCH = arm
}
因此,在 .pro
文件中我无法检测到目标架构(它始终是 arm
)。我可以检查 CONFIG
的 iphonesimulator
值,然后检测 arm/not arm 架构,但仍然存在 32 位/64 位问题。
有没有办法区分armv7/arm64/...在qmake(.pro文件)中构建?
我找到的唯一方法是:
Qt Creator → 首选项 → 构建和 运行 / 工具包 → 环境 → 更改...
比为每个套件设置特定的 IOS_ARCH
环境变量。
在 .pro
文件中:
IOS_ARCH = $$(IOS_ARCH)
!isEmpty(IOS_ARCH): TARGET_ARCH = $$IOS_ARCH
# then use $$TARGET_ARCH as usual
我有一个支持以下 ABI 的 Qt 版本(Qt Creator → Preferences → Build & 运行 / Qt Versions):
- arm-macos-generic-mach_o-32bit
- arm-macos-generic-mach_o-64bit
- x86-macos-generic-mach_o-32bit
- x86-macos-generic-mach_o-64bit
因此,将此 Qt 版本与不同的编译器结合在一个 Qt 套件中,我可以为所有提到的架构构建库。
同时mkspecs/qconfig.pri
包含:
host_build {
QT_ARCH = x86_64
QT_TARGET_ARCH = arm
} else {
QT_ARCH = arm
}
因此,在 .pro
文件中我无法检测到目标架构(它始终是 arm
)。我可以检查 CONFIG
的 iphonesimulator
值,然后检测 arm/not arm 架构,但仍然存在 32 位/64 位问题。
有没有办法区分armv7/arm64/...在qmake(.pro文件)中构建?
我找到的唯一方法是:
Qt Creator → 首选项 → 构建和 运行 / 工具包 → 环境 → 更改...
比为每个套件设置特定的 IOS_ARCH
环境变量。
在 .pro
文件中:
IOS_ARCH = $$(IOS_ARCH)
!isEmpty(IOS_ARCH): TARGET_ARCH = $$IOS_ARCH
# then use $$TARGET_ARCH as usual