From 437d23710f8838bb43999b97e5cd423c0eca3c43 Mon Sep 17 00:00:00 2001
From: Aimee Linden <aimee@lindenlab.com>
Date: Thu, 22 Apr 2010 16:09:54 +0100
Subject: [PATCH] EXT-7004 : Select GCC 4.0 automatically as the compiler in
 Xcode with Cmake 2.8.1

GCC 4.0 will be selected as the compiler in Xcode if building against the OS X 10.4 SDK which is incompatible with GCC 4.2

Also made it possible to override the selected SDK from the configure line, by using something like:
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING='10.4' -DCMAKE_OSX_SYSROOT:PATH='/Developer/SDKs/MacOSX10.5.sdk'

Reviewed by: Poppy.
---
 indra/cmake/Variables.cmake  | 31 +++++++++++++++++++++++++++----
 indra/newview/CMakeLists.txt |  6 +++---
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index db0b44eb8f0..bfaf3f4f26f 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -75,11 +75,33 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 
 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   set(DARWIN 1)
-  # set this dynamically from the build system now -
-  # NOTE: wont have a distributable build unless you add this on the configure line with:
+
+  # NOTE: If specifying a different SDK with CMAKE_OSX_SYSROOT at configure
+  # time you should also specify CMAKE_OSX_DEPLOYMENT_TARGET explicitly,
+  # otherwise CMAKE_OSX_SYSROOT will be overridden here. We can't just check
+  # for it being unset, as it gets set to the system default :(
+
+  # Default to building against the 10.4 SDK if no deployment target is
+  # specified.
+  if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
+    # NOTE: setting -isysroot is NOT adequate: http://lists.apple.com/archives/Xcode-users/2007/Oct/msg00696.html
+    # see http://public.kitware.com/Bug/view.php?id=9959 + poppy
+    set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk)
+    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.4)
+  endif (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
+
+  # GCC 4.2 is incompatible with the MacOSX 10.4 SDK
+  if (${CMAKE_OSX_SYSROOT} MATCHES "10.4u")
+    set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "4.0")
+  endif (${CMAKE_OSX_SYSROOT} MATCHES "10.4u")
+
+  # NOTE: To attempt an i386/PPC Universal build, add this on the configure line:
   # -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc'
-  #set(CMAKE_OSX_ARCHITECTURES i386;ppc)
-  set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk)
+  # Build only for i386 by default, system default on MacOSX 10.6 is x86_64
+  if (NOT CMAKE_OSX_ARCHITECTURES)
+    set(CMAKE_OSX_ARCHITECTURES i386)
+  endif (NOT CMAKE_OSX_ARCHITECTURES)
+
   if (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
     set(ARCH universal)
   else (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
@@ -89,6 +111,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
       set(ARCH i386)
     endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
   endif (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
+
   set(LL_ARCH ${ARCH}_darwin)
   set(LL_ARCH_DIR universal-darwin)
   set(WORD_SIZE 32)
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index efb16d1e421..cc1a79503ee 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1390,7 +1390,7 @@ if (WINDOWS)
 
     # If adding a file to viewer_manifest.py in the WindowsManifest.construct() method, be sure to add the dependency
     # here.
-    # *NOTE:Mani - This is a crappy hack to have important dependecies for the viewer_manifest copy action
+    # *NOTE:Mani - This is a crappy hack to have important dependencies for the viewer_manifest copy action
     # be met. I'm looking forward to a source-code split-up project next year that will address this kind of thing.
     # In the meantime, if you have any ideas on how to easily maintain one list, either here or in viewer_manifest.py
     # and have the build deps get tracked *please* tell me about it.
@@ -1411,7 +1411,7 @@ if (WINDOWS)
     endif(USE_GOOGLE_PERFTOOLS)
   
 
-    set(COPY_INPUT_DEPENDECIES
+    set(COPY_INPUT_DEPENDENCIES
       # The following commented dependencies are determined at variably at build time. Can't do this here.
       #${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/libtcmalloc_minimal.dll => None ... Skipping libtcmalloc_minimal.dll
       ${CMAKE_SOURCE_DIR}/../etc/message.xml
@@ -1507,7 +1507,7 @@ if (WINDOWS)
       DEPENDS 
         ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
         stage_third_party_libs
-        ${COPY_INPUT_DEPENDECIES}
+        ${COPY_INPUT_DEPENDENCIES}
       COMMENT "Performing viewer_manifest copy"
       )
     
-- 
GitLab