Browse Source

Up and running on iOS

Josh Engebretson 9 years ago
parent
commit
bde2a52117
2 changed files with 14 additions and 13 deletions
  1. 11 12
      Build/CMake/Modules/AtomicIOS.cmake
  2. 3 1
      Source/Atomic/Engine/Application.cpp

+ 11 - 12
Build/CMake/Modules/AtomicIOS.cmake

@@ -7,24 +7,23 @@ set (JAVASCRIPT_BINDINGS_PLATFORM "IOS")
 add_definitions (-DIOS -DATOMIC_PLATFORM_IOS -DATOMIC_OPENGL -DKNET_UNIX -DATOMIC_TBUI)
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -std=gnu++0x")
 
-# set the architecture for iOS
-#if (${IOS_PLATFORM} STREQUAL "OS")
-#    set (IOS_ARCH armv7 armv7s arm64)
-#elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
-#    set (IOS_ARCH i386)
-# elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR64")
-#    set (IOS_ARCH x86_64)
-#endif (${IOS_PLATFORM} STREQUAL "OS")
+set (CMAKE_CROSSCOMPILING TRUE)
+set (CMAKE_XCODE_EFFECTIVE_PLATFORMS -iphoneos -iphonesimulator)
+set (CMAKE_OSX_SYSROOT iphoneos)    # Set Base SDK to "Latest iOS"
+set (CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
 
 set (CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_INCLUDING_64_BIT))
-set (CMAKE_XCODE_EFFECTIVE_PLATFORMS -iphoneos -iphonesimulator)
 
-# Set Base SDK to "Latest iOS"
-set (CMAKE_OSX_SYSROOT iphoneos)
+# This is a CMake hack in order to make standard CMake check modules that use try_compile() internally work on iOS platform
+# The injected "flags" are not compiler flags, they are actually CMake variables meant for another CMake subprocess that builds the source file being passed in the try_compile() command
+# CAVEAT: these injected "flags" must always be kept at the end of the string variable, i.e. when adding more compiler flags later on then those new flags must be prepended in front of these flags instead
+set (CMAKE_REQUIRED_FLAGS ";-DSmileyHack=byYaoWT;-DCMAKE_MACOSX_BUNDLE=1;-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=0")
 
 # Obtain iOS sysroot path
 execute_process (COMMAND xcodebuild -version -sdk ${CMAKE_OSX_SYSROOT} Path OUTPUT_VARIABLE IOS_SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
 
+message (${IOS_SYSROOT})
+
 set (CMAKE_FIND_ROOT_PATH ${IOS_SYSROOT})
 
-set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AudioToolbox -framework CoreAudio -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit")
+set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AudioToolbox -framework CoreAudio -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit -framework CoreMotion -framework GameController")

+ 3 - 1
Source/Atomic/Engine/Application.cpp

@@ -28,7 +28,9 @@
 
 #ifdef IOS
 #include "../Graphics/Graphics.h"
-#include <SDL/SDL.h>
+// ATOMIC BEGIN
+#include <SDL/include/SDL.h>
+// ATOMIC END
 #endif
 
 #include "../DebugNew.h"