History: Building From Source - iPhone
Preview of version: 24
Prerequisites
This article assumes that you have already downloaded and installed CMake, and obtained the Ogre source. For instructions on obtaining the Ogre source via Mercurial, see Building Ogre.
If you want to test your build on an iOS device (instead of just the simulator), you should also have obtained an App ID from the iOS Provisioning Portal on developer.apple.com.
Obtaining Dependencies
Head over to http://sourceforge.net/projects/ogre/files/ogre-dependencies-mac/ and download the latest iPhone dependencies package. Once it has finished downloading, double-click on the disc image to mount it. Copy the iPhoneDependencies folder to the root of the Ogre source tree. It should reside alongside folders such as OgreMain, Samples, Tests, PlugIns, etc.
Your Ogre directory should look similar to this:
CMake Components iPhoneDependencies Docs OgreMain Other PlugIns RenderSystems Samples SDK Tests Tools
Building
Two common build cases are:
Build for running the sample projects.
Build for compatibility with Ogre's "iPhone OS" Xcode project template.
These two cases are detailed below.
For Running the Sample Projects
The best way to configure for iPhone is using Terminal. Using CMake-Gui doesn't quite configure correctly at the time of this writing.
First change to the directory of the Ogre sources. Now create a build directory and change to it:
mkdir build && cd build
You need to run cmake from the build directory and provide it with the location of the build directory. If you followed the above guideline, then you can simply type:
cmake -D OGRE_BUILD_PLATFORM_IPHONE=1 -G Xcode ..
CMake will now parse the scripts in the Ogre source tree. Watch the output, especially if all necessary dependencies have been found. If not, you might need to install the missing ones or provide their locations manually.
A Xcode project has now been generated in the build directory, so to start the Ogre build, open OGRE.xcodeproj and build as usual.
To run samples on your device you will need to have a valid iPhone Developer certificate installed. For each sample, double click on target in the Groups & Files list. Ensure that a valid identity is selected in the Code Signing Identity drop menu.
Also, because we can't tell CMake what Xcode project format you want, you will have to change it yourself. Open the Project Menu, choose Edit Project Settings. Click on the General tab in the settings window. Change Project Format to Xcode 3.1-compatible. If you are using CMake 2.8 it is not necessary to change the Project Format.
And another thing. You will need to manually set the Bundle Identifier property of the Info.plist file to match the App ID of the chosen code signing identity. This can be done from the Target Properties panel. It must match the bundle identifier of a valid developer certificate if you are building for devices.
For Compatibility with the Template Project
If you want to use the Xcode template installer package after building the source, use the script below to create and modify your build directory so it matches the pre-built SDK.
NOTE: This revision of the script is work-in-progress and will be improved over the next few days. At present, it should work for deployment to the device but not the simulator. Modify the global variables depending on your own directory paths.
#!/bin/bash #################### # GLOBAL VARIABLES # #################### # Absolute path to the source code directory. SRC=`pwd`/ogre_src # Absolute path to the iPhoneDependencies directory. DEP=$SRC/iPhoneDependencies # Absolute path to the build directory. BUILD=`pwd`/OgreSDK_iOS #################### # Clear the old build and recompile the new one. rm -rf $BUILD mkdir $BUILD cd $BUILD cmake -D OGRE_BUILD_PLATFORM_IPHONE=1 -G Xcode $SRC cd $BUILD xcodebuild -sdk iphoneos -configuration Release # Copy the iPhoneDependencies directory. cp -R $DEP $BUILD # Standardize the lib/* directories. mkdir $BUILD/lib/pkgconfig # Add necessary files to the Debug directory. cp $DEP/lib/Debug/* $BUILD/lib/Debug # Add necessary files to the Release directory. cp $DEP/lib/Release/* $BUILD/lib/Release # Add necessary files to the pkgconfig directory. cp $BUILD/pkgconfig/* $BUILD/lib/pkgconfig # Handle the include directory. mkdir $BUILD/include/OGRE mkdir $BUILD/include/OGRE/iPhone mkdir $BUILD/include/OGRE/Paging mkdir $BUILD/include/OGRE/Plugins mkdir $BUILD/include/OGRE/Plugins/BSPSceneManager mkdir $BUILD/include/OGRE/Plugins/OctreeSceneManager mkdir $BUILD/include/OGRE/Plugins/OctreeZone mkdir $BUILD/include/OGRE/Plugins/ParticleFX mkdir $BUILD/include/OGRE/Plugins/PCZSceneManager mkdir $BUILD/include/OGRE/Property mkdir $BUILD/include/OGRE/RenderSystems mkdir $BUILD/include/OGRE/RenderSystems/GLES mkdir $BUILD/include/OGRE/RenderSystems/GLES/APPLE mkdir $BUILD/include/OGRE/RTShaderSystem mkdir $BUILD/include/OGRE/Terrain mkdir $BUILD/include/OGRE/Threading mv $BUILD/include/OgreBuildSettings.h $BUILD/include/OGRE cp $SRC/OgreMain/include/*.h $BUILD/include/OGRE cp $BUILD/Samples/include/ExampleApplication.h $BUILD/include/OGRE cp $BUILD/Samples/include/ExampleFrameListener.h $BUILD/include/OGRE cp $BUILD/Samples/include/ExampleLoadingBar.h $BUILD/include/OGRE cp $BUILD/Samples/include/FileSystemLayer.h $BUILD/include/OGRE cp $BUILD/Samples/include/Sample.h $BUILD/include/OGRE cp $BUILD/Samples/include/SampleContext.h $BUILD/include/OGRE cp $BUILD/Samples/include/SamplePlugin.h $BUILD/include/OGRE cp $BUILD/Samples/include/SdkCameraMan.h $BUILD/include/OGRE cp $BUILD/Samples/include/SdkSample.h $BUILD/include/OGRE cp $BUILD/Samples/include/SdkTrays.h $BUILD/include/OGRE cp $SRC/OgreMain/include/iPhone/* $BUILD/include/OGRE/iPhone cp $SRC/Components/Paging/include/* $BUILD/include/OGRE/Paging cp $SRC/Plugins/BSPSceneManager/include/* $BUILD/include/OGRE/Plugins/BSPSceneManager cp $SRC/Plugins/OctreeSceneManager/include/* $BUILD/include/OGRE/Plugins/OctreeSceneManager cp $SRC/Plugins/OctreeZone/include/* $BUILD/include/OGRE/Plugins/OctreeZone cp $SRC/Plugins/ParticleFX/include/* $BUILD/include/OGRE/Plugins/ParticleFX cp $SRC/Plugins/PCZSceneManager/include/* $BUILD/include/OGRE/Plugins/PCZSceneManager cp $SRC/Components/Property/include/* $BUILD/include/OGRE/Property cp $SRC/RenderSystems/GLES/include/*.h $BUILD/include/OGRE/RenderSystems/GLES cp $SRC/RenderSystems/GLES/include/EAGL/* $BUILD/include/OGRE/RenderSystems/GLES/APPLE cp $SRC/Components/RTShaderSystem/include/* $BUILD/include/OGRE/RTShaderSystem cp $SRC/Components/Terrain/include/* $BUILD/include/OGRE/Terrain cp $SRC/OgreMain/include/Threading/* $BUILD/include/OGRE/Threading # Handle the Media directory. cp -R $SRC/Samples/Media $BUILD/media # Handle the Samples directory. cp -R $SRC/Samples $BUILD/Samples # Remove the extra copy of the Media directory. rm -rf $BUILD/Samples/Media
Alias: Building From Source (for iPhone)