From d4fa9e0cb694d108e46cd2f63fa3c03398025760 Mon Sep 17 00:00:00 2001
From: auria <auria@178a84e3-b1eb-0310-8ba1-8eac791a3b58>
Date: Wed, 13 Mar 2013 04:03:26 +0000
Subject: [PATCH] Finalize integration of cmake build on osx with builtin
 irrlicht

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12548 178a84e3-b1eb-0310-8ba1-8eac791a3b58
---
 CMakeLists.txt              |  4 ++--
 cmake/FindFribidi.cmake     | 35 +++++++++++++++++++++--------------
 lib/irrlicht/CMakeLists.txt | 30 ++++++++++++++++++++++++++++--
 3 files changed, 51 insertions(+), 18 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e50260acb..6088cb9bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
 # root CMakeLists for the SuperTuxKart project
 project(SuperTuxKart)
-set(PROJECT_VERSION "0.7.3")
+set(PROJECT_VERSION "0.8.1")
 
 cmake_minimum_required(VERSION 2.8.1)
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
@@ -153,7 +153,7 @@ if(APPLE)
         MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/src/ide/Xcode/SuperTuxKart-Info.plist)
 
     add_custom_command(TARGET supertuxkart PRE_BUILD
-        COMMAND ln -s ${PROJECT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/bin/supertuxkart.app/Contents/Resources)
+        COMMAND ln -f -s ${PROJECT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/bin/supertuxkart.app/Contents/Resources)
 else()
     find_library(PTHREAD_LIBRARY NAMES pthread pthreadVC2 PATHS ${PROJECT_SOURCE_DIR}/dependencies/lib)
     mark_as_advanced(PTHREAD_LIBRARY)
diff --git a/cmake/FindFribidi.cmake b/cmake/FindFribidi.cmake
index da8754ccc..5d772f041 100644
--- a/cmake/FindFribidi.cmake
+++ b/cmake/FindFribidi.cmake
@@ -9,27 +9,34 @@
 # FRIBIDI_LIBRARIES
 #     Fribidi library list
 
-if(UNIX)
-	include(FindPkgConfig)
-	pkg_check_modules(FRIBIDI fribidi)
+if(APPLE)
+    set(FRIBIDI_INCLUDE_DIR NAMES fribidi/fribidi.h PATHS /Library/Frameworks/fribidi.framework/Headers)
+    find_library(FRIBIDI_LIBRARY NAMES fribidi PATHS /Library/Frameworks/fribidi.framework)
+    set(FRIBIDI_LIBRARIES ${FRIBIDI_LIBRARY})
+    include_directories(/Library/Frameworks/fribidi.framework/Headers)
+    #add_definitions(-framework fribidi)
+    set(FRIBIDI_FOUND 1)
+elseif(UNIX)
+    include(FindPkgConfig)
+    pkg_check_modules(FRIBIDI fribidi)
 else()
-	set(FRIBIDI_FOUND 0)
+    set(FRIBIDI_FOUND 0)
 endif()
 
 if(NOT FRIBIDI_FOUND)
-	find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi/fribidi.h PATHS /Library/Frameworks/fribidi.framework/Headers "${PROJECT_SOURCE_DIR}/dependencies/include")
-	find_library(FRIBIDI_LIBRARY NAMES fribidi PATHS /Library/Frameworks/fribidi.framework "${PROJECT_SOURCE_DIR}/dependencies/lib")
+    find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi/fribidi.h PATHS /Library/Frameworks/fribidi.framework/Headers "${PROJECT_SOURCE_DIR}/dependencies/include")
+    find_library(FRIBIDI_LIBRARY NAMES fribidi PATHS /Library/Frameworks/fribidi.framework "${PROJECT_SOURCE_DIR}/dependencies/lib")
 
-	include(FindPackageHandleStandardArgs)
-	find_package_handle_standard_args(Fribidi DEFAULT_MSG FRIBIDI_INCLUDE_DIR FRIBIDI_LIBRARY)
+    include(FindPackageHandleStandardArgs)
+    find_package_handle_standard_args(Fribidi DEFAULT_MSG FRIBIDI_INCLUDE_DIR FRIBIDI_LIBRARY)
 
-	if(APPLE)
-		set(FRIBIDI_INCLUDE_DIR "/Library/Frameworks/fribidi.framework/Headers")
-	endif()
+    if(APPLE)
+            set(FRIBIDI_INCLUDE_DIR "/Library/Frameworks/fribidi.framework/Headers")
+    endif()
 
-	# Publish variables
-	set(FRIBIDI_INCLUDE_DIRS ${FRIBIDI_INCLUDE_DIR})
-	set(FRIBIDI_LIBRARIES ${FRIBIDI_LIBRARY})
+    # Publish variables
+    set(FRIBIDI_INCLUDE_DIRS ${FRIBIDI_INCLUDE_DIR})
+    set(FRIBIDI_LIBRARIES ${FRIBIDI_LIBRARY})
 endif()
 
 mark_as_advanced(FRIBIDI_INCLUDE_DIR FRIBIDI_LIBRARY)
diff --git a/lib/irrlicht/CMakeLists.txt b/lib/irrlicht/CMakeLists.txt
index b05d93c6f..174da6d00 100644
--- a/lib/irrlicht/CMakeLists.txt
+++ b/lib/irrlicht/CMakeLists.txt
@@ -6,13 +6,16 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/
                     ${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/zlib
                     ${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/bzip2)
 
+if(APPLE)
+    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/MacOSX ${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht)
+endif()
+
 add_definitions(-Wall -pipe -fexpensive-optimizations -I/usr/X11R6/include -DIRRLICHT_EXPORTS=1 -DNDEBUG=1)
 
 set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O3  -fno-exceptions -fno-rtti -fstrict-aliasing")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES")
 
-
-add_library(stkirrlicht
+set(IRRLICHT_SOURCES
 source/Irrlicht/CTRStencilShadow.cpp
 source/Irrlicht/CGUIListBox.cpp
 source/Irrlicht/CZBuffer.cpp
@@ -774,3 +777,26 @@ source/Irrlicht/libpng/pnginfo.h
 source/Irrlicht/libpng/pnglibconf.h
 source/Irrlicht/libpng/pngstruct.h
 )
+
+if(APPLE)
+    set(IRRLICHT_SOURCES
+        ${IRRLICHT_SOURCES}
+        source/Irrlicht/MacOSX/AppDelegate.mm
+        source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
+        source/Irrlicht/MacOSX/OSXClipboard.mm)
+    
+    #list(APPEND CMAKE_C_SOURCE_FILE_EXTENSIONS mm)
+    #set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS cpp)
+    
+    set_source_files_properties(source/Irrlicht/MacOSX/AppDelegate.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3  -fno-rtti")
+    set_source_files_properties(source/Irrlicht/MacOSX/AppDelegate.mm PROPERTIES LANGUAGE C)
+    
+    set_source_files_properties(source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3  -fno-rtti")
+    set_source_files_properties(source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm PROPERTIES LANGUAGE C)
+    
+    set_source_files_properties(source/Irrlicht/MacOSX/OSXClipboard.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti")
+    set_source_files_properties(source/Irrlicht/MacOSX/OSXClipboard.mm PROPERTIES LANGUAGE C)
+endif()
+
+add_library(stkirrlicht ${IRRLICHT_SOURCES})
+