From 73331eebf885ba8918447d26ba37bef2208bdb5e Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Tue, 23 Aug 2016 15:16:42 -0700 Subject: Enable precompiled headers on iOS, tvOS, watchOS The actual blocker for precompiled headers is not the iOS/tvOS/watchOS platforms, but the way qmake handled multiple-architecture builds on Apple platforms. This patch allows multi-arch builds to be performed while using precompiled headers. Since df91ef3d6c55692a0236f67b6c6b134a3bf84098 (April 2009), Clang has had support for PCH files in the driver, which allows to use the -include flag to automatically translate to -include-pch. We can then take advantage of the fact that the -include option is allowed to not be separate from its argument, which lets us take advantage of -Xarch to specify a per-architecture precompiled header file. This is done through some magic in the qmake Makefile generator which "multiplexes" the PCH creation rule across multiple architectures and replaces a series of tokens with the proper precompiled header paths and architecture flags at usage point. Change-Id: I76c8dc9cda7e218869c2919f023d9b04f311c6fd Reviewed-by: Oswald Buddenhagen --- mkspecs/features/mac/sdk.prf | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'mkspecs/features/mac/sdk.prf') diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf index 5abc741b90..c7395ea572 100644 --- a/mkspecs/features/mac/sdk.prf +++ b/mkspecs/features/mac/sdk.prf @@ -56,13 +56,32 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_ !equals(MAKEFILE_GENERATOR, XCODE) { uikit:!host_buildĀ { - simulator: \ + ios: os_var = IOS + tvos: os_var = TVOS + watchos: os_var = WATCHOS + + deployment_target = $$eval(QMAKE_$${os_var}_DEPLOYMENT_TARGET) + simulator { + archs = $$eval(QMAKE_$${os_var}_SIMULATOR_ARCHS) version_identifier = $$simulator.deployment_identifier - else: \ + } else { + archs = $$eval(QMAKE_$${os_var}_DEVICE_ARCHS) version_identifier = $$device.deployment_identifier - ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET - tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET - watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET + } + + single_arch: archs = $$first(archs) + + QMAKE_CFLAGS_USE_PRECOMPILE = + for(arch, archs) { + QMAKE_CFLAGS_USE_PRECOMPILE += \ + -Xarch_$${arch} \ + -include${QMAKE_PCH_OUTPUT_$${arch}} + } + QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + + QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT} } else: osx { version_identifier = macosx deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET -- cgit v1.2.3