From 0e379977346004a52fb8648f16062ad2a894d4a8 Mon Sep 17 00:00:00 2001
From: Marco Antognini <antognini.marco@gmail.com>
Date: Wed, 30 Mar 2011 19:52:36 +0200
Subject: [PATCH] CMake : add support for ppc arch and 10.5 SDK

---
 CMakeLists.txt | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f06b473a..6a16a35b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,7 +28,16 @@ set(BUILD_SHARED_LIBS TRUE CACHE BOOL "TRUE to build SFML as shared libraries, F
 set(BUILD_EXAMPLES FALSE CACHE BOOL "TRUE to build the SFML examples, FALSE to ignore them")
 
 # add an option for building the API documentation
-set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
+set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
+
+# Mac OS X specific options
+if (MACOSX)
+    # add an option to compile ppc/ppc64
+    set(BUILD_PPC FALSE CACHE BOOL "TRUE to build SFML for ppc and ppc64, too, FALSE to only compile i386 and x86_64")
+
+    # add an option to build against 10.5 SDK
+    set(BUILD_LEOPARD FALSE CACHE BOOL "TRUE to build SFML for OS X 10.5, FALSE to compile for default SDK")
+endif()
 
 # define SFML_STATIC if the build type is not set to 'shared'
 if(NOT BUILD_SHARED_LIBS)
@@ -55,7 +64,40 @@ if(COMPILER_MSVC)
 endif()
 
 # disable the rpath stuff
-set(CMAKE_SKIP_BUILD_RPATH TRUE)
+set(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+# Setup Mac OS X multi arch/SDK support.
+if (MACOSX)
+    # compile for PPC ?
+    if (BUILD_PPC)
+        if (NOT CMAKE_OSX_ARCHITECTURES)
+            # Custom : ppc, ppc64, i386 and x86_64
+            set(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64")
+        else()
+            # We got some conflict with custom user settings ; let him know his on his own.
+            message("You set BUILD_PPC to TRUE but CMAKE_OSX_ARCHITECTURES is not empty.")
+            message("You're on your own : I won't change your settings.")
+        endif()
+    else()
+        if (NOT CMAKE_OSX_ARCHITECTURES)
+            # Default : i386 and x86_64
+            set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
+        else()
+            # We got some conflict with custom user settings ; let him know his on his own.
+            message("CMAKE_OSX_ARCHITECTURES is not empty.")
+            message("You're on your own : I won't change your settings.")
+        endif()
+    endif()
+
+    # use 10.5 SDK ?
+    if (BUILD_LEOPARD)
+        # Use 10.5 SDK : override default value
+        set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk")
+        set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5")
+    else()
+        # Default SDK, let either the user or CMake decide which one to use.
+    endif()
+endif()
 
 # add the subdirectories
 add_subdirectory(src/SFML)