From 3d0a60aaa4077a897d02ca5f3c0cc2d7da1007c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@digia.com>
Date: Wed, 3 Apr 2013 15:05:06 +0200
Subject: [PATCH] Enable C++11 on OSX when using Clang
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This means we have to bump the deployment target to Lion (10.7), as the
LLVM 'libc++' C++ standard library does not support Snow Leopard (10.6).

For iOS the deployment target has to be bumped from 4.3 to 5.0, but we
don't enable C++11 by default yet as it's not tested enough on iOS.

Users who wish to deploy to 10.6 need to build their own Qt,
passing -no-c++11 to configure.

Change-Id: I7b5d20ab002db889d1091a4b7ff600f62caa7f06
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
---
 configure                     | 4 ++--
 mkspecs/common/clang-mac.conf | 3 +++
 mkspecs/features/c++11.prf    | 7 +++++++
 mkspecs/features/mac/sdk.prf  | 3 +++
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 4de2fbb714b..99738868d97 100755
--- a/configure
+++ b/configure
@@ -2814,9 +2814,9 @@ if [ "$CFG_FORCEDEBUGINFO" = "yes" ]; then
     QMAKE_CONFIG="$QMAKE_CONFIG force_debug_info"
 fi
 
-# iOS builds should be static to be able to submit to the App Store
 if [ "$XPLATFORM_IOS" = "yes" ]; then
-    CFG_SHARED="no"
+    CFG_SHARED="no" # iOS builds should be static to be able to submit to the App Store
+    CFG_CXX11="no" # C++11 support disabled for now
 fi
 
 # disable GTK style support auto-detection on Mac
diff --git a/mkspecs/common/clang-mac.conf b/mkspecs/common/clang-mac.conf
index efe771d24de..3280274f369 100644
--- a/mkspecs/common/clang-mac.conf
+++ b/mkspecs/common/clang-mac.conf
@@ -5,3 +5,6 @@ QMAKE_OBJCXXFLAGS_PRECOMPILE     = -x objective-c++-header -c ${QMAKE_PCH_INPUT}
 QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
 
 QMAKE_XCODE_GCC_VERSION = com.apple.compilers.llvm.clang.1_0
+
+QMAKE_CXXFLAGS_CXX11 += -stdlib=libc++
+QMAKE_LFLAGS_CXX11   += -stdlib=libc++
diff --git a/mkspecs/features/c++11.prf b/mkspecs/features/c++11.prf
index 4b56fa9fd24..32eaca4a9b5 100644
--- a/mkspecs/features/c++11.prf
+++ b/mkspecs/features/c++11.prf
@@ -1,3 +1,10 @@
 QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_CXX11
 QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CXXFLAGS_CXX11
 QMAKE_LFLAGS += $$QMAKE_LFLAGS_CXX11
+
+contains(QMAKE_LFLAGS, -stdlib=libc++) {
+    equals(QMAKE_MACOSX_DEPLOYMENT_TARGET, 10.6): \
+        QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
+    contains(QMAKE_IOS_DEPLOYMENT_TARGET, ^4.*): \
+        QMAKE_IOS_DEPLOYMENT_TARGET = 5.0
+}
diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf
index eaa3108a8bc..10d94bed11d 100644
--- a/mkspecs/features/mac/sdk.prf
+++ b/mkspecs/features/mac/sdk.prf
@@ -40,6 +40,9 @@ isEmpty(QMAKE_MAC_PLATFORM_NAME): error("Could not resolve platform name for SDK
     # FIXME: Get the version_min_flag out of the platform's 'Native Build System.xcspec'
     version_identifier = $$replace(QMAKE_MAC_PLATFORM_NAME, iphonesimulator, ios-simulator)
 
+    # C++11 support may affect the deployment target
+    c++11: load(c++11)
+
     ios:!host_build: \
         deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
     else: \
-- 
GitLab