History: CMake Quick Start Guide
Preview of version: 43
- «
- »
Introduction
This guide is designed to get you building OGRE from source with the default settings in the shortest possible time, showing you the barest minimum of CMake to do that, and minus any real discussion. Remember that there is a lot more to the hows and whys of this process, so it's a good idea to go back to the Getting Started With CMake page and read the whole thing when you have time.
We assume here that you've already downloaded / extracted the OGRE source code into a folder on your local machine. From here, go to the section for your platform.
Make sure that you've sorted out the Prerequisites before attempting to build Ogre with CMake!
- Make sure you have downloaded, extracted and built the dependencies package
- Download CMake. You want the 'Win32 installer' release in the binary distribution section
- Run the CMake installer, install wherever you like
- Launch CMake via Start > Program Files > CMake 2.8 > CMake
- In the "Where is the source code" box, type or browse to the root directory of your OGRE source (the one that contains the OgreMain folder)
- In the "Where to build the binaries" box, type or browse to any folder you like - this will be where the build output will go (libraries, headers, dlls & sample exes). The folder does not have to exist yet. Note that you can run this process more than once with different output folders if you want (but we won't complicate matters now)
- Hit the 'Configure' button near the bottom of the screen
- Pick your target compiler, e.g. "Visual Studio 8 2005"
- Answer 'Ok' when asked if you want to create the build directory
- Wait for the configure process to finish
- The screen will now have a bunch of configuration options on it, which will be red (this is to indicate this is the first time you've seen them). You can see the potential for customising your build here, but for now just click the 'Configure' button again
- The values will turn grey, and the 'Generate' button at the bottom will now be enabled. Click 'Generate'
- Build files will now be generated in the location you picked, and CMake will say "Generating done"
That's it for CMake! You now have a set of project files that are very much like you're used to in previous versions of OGRE, in the output folder you chose. Just browse there and open the main project file (e.g. OGRE.sln). You can build as before, but there is now a special target called 'ALL_BUILD' which is a quick way to build all targets for a specific configuration. Note that all build output is now stored in a subfolder of this build folder, and not in the original OGRE source folder - so you can create multiple builds from one source directory now.
-(Linux)--------
Make sure that you've sorted out the Prerequisites before attempting to build Ogre with CMake!
- Download Ogre Source (Instructions below assume current version of 1.8.0, update as needed)
- Decompress:Copy to clipboardtar xjf ogre_src_v1-8-0.tar.bz2
- Move to source directory:Copy to clipboardcd ogre_src_v1-8-0
- Create build directory:Copy to clipboardmkdir build
- Move into build directory:Copy to clipboardcd build
- Trigger cmake, passing path to Ogre source directory:See the Extensive CMake page for a list of compilation options which can be passed to CMake at this stage, and Getting Started With CMake for even more background material. N.B. Please note that OGRE_CONFIG_THREADS = 1 is not supported on Linux.Copy to clipboardcmake ..
- If the CMake results look good, build Ogre:The -j2 specifies how many parallel compilation jobs to run. Substitute the number of processor cores on your system, e.g. -j2 for a dual-core, -j4 for a quad core...Copy to clipboardmake -j2
- Once compilation is successful, you can install into the system (by default, /usr/local):Copy to clipboardsudo make install
-(Mac OS X)--------
Make sure that you've sorted out the Prerequisites before attempting to build Ogre with CMake!
Building Ogre via CMake GUI (see alt. command line below)
Xcode 4.3 changed the layout of developer tools on disk which can cause some serious problems for CMake. The issue has been fixed but is not yet publicly released. CMake 2.8.8 will include Xcode 4.3 support. At the time of writing, a release candidate is available that includes this support.
You will also need to install the Command Line Tools from within Xcode's Downloads Preferences and set the Xcode path from the command line like this.
Assuming that Xcode is installed in /Applications,
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
- Download CMake. You want the 'Mac OS X Universal' release in the binary distribution section
- The .dmg will probably auto-mount when it downloads, if not, double-click it to open
- Double-click the .pkg installer, install on your main drive and opt to install the command-line tools too (in case you want to use them later, we will use the GUI here)
- Launch CMake via Applications
- In the "Where is the source code" box, type or browse to the root directory of your OGRE source (the one that contains the OgreMain folder)
- In the "Where to build the binaries" box, type or browse to any folder you like - this will be where the build output will go (libraries, headers, dlls & sample exes). The folder does not have to exist yet. Note that you can run this process more than once with different output folders if you want (but we won't complicate matters now)
- Hit the 'Configure' button near the bottom of the screen
- Pick 'Xcode' as the generator and opt to use native compilers
- Answer 'Ok' when asked if you want to create the build directory
- Wait for the configure process to finish
- The screen will now have a bunch of configuration options on it, which will be red (this is to indicate this is the first time you've seen them). You can see the potential for customising your build here, but for now just click the 'Configure' button again
- The values will turn grey, and the 'Generate' button at the bottom will now be enabled. Click 'Generate'
- Build files will now be generated in the location you picked
- Now, open OGRE.xcodeproj in the build directory you picked, open it in Xcode. SampleBrowser will build everything!
Note: ALL_BUILD does not work properly with Xcode 4.
Building Ogre via Command Line (see alt. GUI method above)
- Download Ogre Source (Instructions below assume current version of 1.8.0, update as needed)
- Decompress:Copy to clipboardtar xjf ogre_src_v1-8-0.tar.bz2
- Move to source directory:Copy to clipboardcd ogre_src_v1-8-0
- Create build directory:Copy to clipboardmkdir build
- Move into build directory:Copy to clipboardcd build
- Trigger cmake, specify Xcode generation and pass path to Ogre source directory:See the Extensive CMake page for a list of compilation options which can be passed to CMake at this stage, and Getting Started With CMake for even more background material.Copy to clipboardcmake -GXcode ..
- Build via Xcode(or open OGRE.xcodeproj and build within Xcode)Copy to clipboardxcodebuild -configuration RelWithDebInfo
Installing Ogre
You will find Ogre.framework in 'lib' within your build directory. You can embed this in your application bundle, or drag it to /Library/Frameworks for system-wide installation.
You will also find plugins (Plugin_*.dylib and RenderSystem_GL.dylib) in the same location, you can copy these to the framework's Resource directory or your own application's bundle. Be sure to configure you applications' plugins.cfg to match (e.g. /Library/Frameworks/Ogre.framework/Resources/)
-(iPhone)--------
Detailed instructions on building OGRE for iPhone can be found on this page Building From Source (for iPhone)
-(Android)--------
Download the dependencies and extract inside the OGRE src dir. The deps are compiled for armeabi and armeabi-v7a.
http://sourceforge.net/projects/ogre/files/ogre-dependencies-android/1.9/AndroidDependencies.zip/download
Windows:
http://developer.android.com/sdk/index.html
2. After the install open the "Android SDK Manager" and download & install your target API.
Here we target the lowest possible API - which is API10 Android 2.3.3.
Due the usage of the native activity and the asset manager if we would skip these we could go a bit lower but that would not make much sense because OGRE still needs a decent hardware to run.
3. Now add the install directory to your enviroment variables -> ANDROID_SDK = C:\Users\wolfmanfx\AppData\Local\Android\android-sdk
- Append %ANDROID_SDK%\tools and %ANDROID_SDK%\platform-tools to your PATH variable
4. Download the android ndk
- Extract the content to C:/android/ndk and create a env var %ANDROID_NDK%
- Add %ANDROID_NDK% to your path
http://dl.google.com/android/ndk/android-ndk-r8-windows.zip Android NDK revision 8b is not supported due a bug in the toolchain
5. We need ant (http://ant.apache.org/bindownload.cgi) to build projects from the command line
- I use this version http://tweedo.com/mirror/apache//ant/binaries/apache-ant-1.8.4-bin.zip
- Extract the content under C:/android/ant and add the bin dir to your path
- Use the command "ant -version" with the windows terminal (cmd.exe) to the test version. Should look like this
Apache Ant(TM) version 1.8.4 compiled on May 22 2012
6. The build command for the deps (using Visual Studio command prompt)
cmake -G"NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\cmake\android.toolchain.cmake -DANDROID_ABI=armeabi .. nmake
7. The build command for ogre (for armeabi - if you want to build for armeabi v7a just remove -DANDROID_ABI=armeabi) create a build dir inside the OGRE src tree and cd to this dir and execute this command:
cmake -G"NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\cmake\toolchain\android.toolchain.cmake -DOGRE_DEPENDENCIES_DIR=..\AndroidDependencies -DANDROID_ABI=armeabi -DANDROID_NATIVE_API_LEVEL=9 ..
OSX:
cmake -DCMAKE_TOOLCHAIN_FILE="`pwd`/../CMake/toolchain/android.toolchain.cmake" -DOGRE_DEPENDENCIES_DIR="`pwd`/../AndroidDependencies" -DANDROID_ABI=armeabi -DANDROID_NATIVE_API_LEVEL=9 ..