From 075c598f92b301a2149697e95e7ce78e7afff8e7 Mon Sep 17 00:00:00 2001
From: Eike Ziller <eike.ziller@nokia.com>
Date: Tue, 17 Jan 2012 10:33:45 +0100
Subject: [PATCH] Mac: Explicitly set architecture to selected tool chain.

The tool chain selection in build configurations had no effect on the
actual build, which is especially visible on Mac with universally built
Qt. The patch passes the tool chain's architecture (+bit width)
explicitly to Qmake. Users can override this behavior as usual by adding
or removing architecture flags from CONFIG in the additional arguments
field.

Task-number: QTCREATORBUG-6088
Change-Id: I92fdb7d5650db6e681945fa82e86422917f84035
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
---
 dist/changes-2.5.0                          |  1 +
 src/plugins/qt4projectmanager/qmakestep.cpp | 27 ++++++++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/dist/changes-2.5.0 b/dist/changes-2.5.0
index 6f87cdd6c89..f3c765be2f0 100644
--- a/dist/changes-2.5.0
+++ b/dist/changes-2.5.0
@@ -59,6 +59,7 @@ Help
 Platform Specific
 
 Mac
+   * Pass architecture and bit width from the tool chain build setting to Qmake (QTCREATORBUG-6088)
 
 Linux (GNOME and KDE)
 
diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp
index bd86f82bd41..bd208cacf8b 100644
--- a/src/plugins/qt4projectmanager/qmakestep.cpp
+++ b/src/plugins/qt4projectmanager/qmakestep.cpp
@@ -166,19 +166,37 @@ QString QMakeStep::allArguments(bool shorted)
 ///
 /// moreArguments,
 /// -unix for Maemo
-/// -after OBJECTS_DIR, MOC_DIR, UI_DIR, RCC_DIR
 /// QMAKE_VAR_QMLJSDEBUGGER_PATH
 QStringList QMakeStep::moreArguments()
 {
     Qt4BuildConfiguration *bc = qt4BuildConfiguration();
     QStringList arguments;
-#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
     ProjectExplorer::ToolChain *tc = bc->toolChain();
-    if (tc && (tc->targetAbi().osFlavor() == ProjectExplorer::Abi::HarmattanLinuxFlavor
-               || tc->targetAbi().osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor))
+    ProjectExplorer::Abi targetAbi;
+    if (tc)
+        targetAbi = tc->targetAbi();
+#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
+    if ((targetAbi.osFlavor() == ProjectExplorer::Abi::HarmattanLinuxFlavor
+               || targetAbi.osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor))
         arguments << QLatin1String("-unix");
 #endif
 
+    // explicitly add architecture to CONFIG
+    if ((targetAbi.os() == ProjectExplorer::Abi::MacOS)
+            && (targetAbi.binaryFormat() == ProjectExplorer::Abi::MachOFormat)) {
+        if (targetAbi.architecture() == ProjectExplorer::Abi::X86Architecture) {
+            if (targetAbi.wordWidth() == 32)
+                arguments << QLatin1String("CONFIG+=x86");
+            else if (targetAbi.wordWidth() == 64)
+                arguments << QLatin1String("CONFIG+=x86_64");
+        } else if (targetAbi.architecture() == ProjectExplorer::Abi::PowerPCArchitecture) {
+            if (targetAbi.wordWidth() == 32)
+                arguments << QLatin1String("CONFIG+=ppc");
+            else if (targetAbi.wordWidth() == 64)
+                arguments << QLatin1String("CONFIG+=ppc64");
+        }
+    }
+
     if (linkQmlDebuggingLibrary() && bc->qtVersion()) {
         if (!bc->qtVersion()->needsQmlDebuggingLibrary()) {
             // This Qt version has the QML debugging services built in, however
@@ -201,6 +219,7 @@ QStringList QMakeStep::moreArguments()
     return arguments;
 }
 
+/// -after OBJECTS_DIR, MOC_DIR, UI_DIR, RCC_DIR
 QStringList QMakeStep::moreArgumentsAfter()
 {
     Qt4BuildConfiguration *bc = qt4BuildConfiguration();
-- 
GitLab