In my previous Ogre3D tutorial for the Mac I showed you how to set up your Mac OSX development environment with the Ogre SDK 1.7.3, install the Xcode templates, and create a sample Ogre project. That’s a great start but what if you wanted to build the samples that came with the Ogre SDK? If you try and use the default Xcode project you’ll receive build errors. To remedy this we have to install a new application called CMake.
Step 1 – Install CMake 2.8.3
The Ogre SDK framework makes use of CMake for creating build scripts (or projects) for the chosen target platform. If you were to build the Ogre3D render engine from source, you’d use CMake to generate a project for Xcode or a Unix Makefile. For building the SDK samples that come with Ogre, it’s the same process in using CMake to generate a working Xcode project to build those samples. To sum it up, we need CMake.
To download CMake 2.8.3 you can click that link you just read over. It’s a Mac DMG disk image. Save it to your Desktop or another location of your choice. Launch the DMG by double-clicking it. Follow the instructions and install CMake to your Mac computer. Check your Applications folder. You should now have CMake 2.8-3 icon. Launch CMake. The User Interface (UI) is to the point (set the source code location, where to build the binaries, and configure the name/value pairs, then build). Next we generate a new Xcode project for the Ogre SDK Samples.
Step 2 – Generate a New Ogre SDK Samples Xcode Project
You’ll need to know where you installed your copy of the Ogre SDK to. Mine is located in the root /OgreSDK. Follow the steps below to generate a new Xcode Project for the Ogre SDK Samples.
- Click the Browse Source button and browse to the location of your Ogre SDK installation (/OgreSDK).
- Click the Browse Build button and choose a location where you’d like the build binaries to be saved to. I use the same location as my SDK install (/OgreSDK).
- Click on the Configure button. Another window will popup asking for what type of project generator (Xcode) and compilers (Use default native compilers) to use.
- CMake will run through the motions and show some Ogre SDK build variables in red. Click the Configure button one more time. After another set of motions you’ll see more concrete CMake variables.
- Click the CMake Generate button to create the Xcode project for building the Ogre SDK Samples. That’s it for CMake. You can close it now.
Step 3 – Modify Settings in the Ogre3D SDK Samples Project
Before we can build the Ogre Samples we need to make a few modifications to our Xcode Ogre Project. Inside /OgreSDK there is a Xcode project called OGRE.xcodeproj. Double-click the Ogre project to launch Xcode. Go ahead and start the build process. You’ll encounter hundreds (if not thousands) of errors. To correct this issue we need to change the build architecture to i386. The Ogre.framework SDK we’re using is prebuilt for i386 so building for any other architecture will fail (unless you build from the source code). Okay, so let’s make the needed changes so we can compile the Ogre Samples.
In Xcode, click on the Project menu, select Edit Active Target “ALL_BUILD”, a dialog window will appear. Make sure you’re on the Build tab and that the Configuration is All Configurations and Show is All Settings. Under the User-Defined Settings, the first property is ARCHS. Double-click and edit the value $(ARCHS_STANDARD_32_BIT). i.e. Take the _64 out of the property value. Save the change and exit the Info window.
Next, click on the Project menu and select Edit Project Settings, the Project Info window appears. Make sure you’re on the Build tab and that the Configuration is All Configurations and Show is All Settings. Under Architecture Settings, the second option Architecture, set the property value to 32-bit Universal. Remove all the other architectures except i386 for the Valid Architectures property. You can now close the Project Info window.
Step 4 – Compile the Ogre3D SDK Samples Project in Xcode
At last, the final step, which is the easiest. Build the Ogre project! Click the Build and Run toolbar button or select it from the Build menu. There are 34 samples to compile so the Ogre Samples Xcode Project will take some time to build. If all goes well (which it should) you’ll have the Ogre Samples running. Explore the Ogre samples. If you encountered compile errors, double-check your project settings.
Say Hello to the Penguin from one of the Ogre Samples Browser. There are 33 more to check out, everything from BSP Scenes, to Shadows, to Skydomes, and more.
More Ogre3D guides to read: