Image

This section explains how to use CMake to build Ogre from source.

Getting the Ogre Sources

First you need to download the Ogre sources. You can get them - surprise! - from the Ogre website. Stable, prepacked source releases can be found under the link "Download -> Source". Alternatively you can get the sources from the Mercurial repository, see "Developers -> Mercurial" for that. Either way keep in mind that the CMake build system covered on this page was added in Ogre version 1.7 (Cthugha), so don't pick anything older than that.

If you downloaded a source archive, you need to unpack it somewhere. A checkout from svn will automatically create an Ogre source directory at the place of your choice. In addition to the source directory, you also need to decide on a build directory - this is the place where CMake will setup a build system for you and where all compiled object files will reside.
If you intend to build Ogre just once and then move on, you can pick any location. If, however, you plan on building Ogre several times, potentially with different configurations (static builds, threaded builds, ...), I recommend to adopt a directory layout similar to the following (but this is up to you):

  • Ogre (the root directory for Ogre building, somewhere on your disk)
    • Sources (Ogre sources of various releases)
      • Cthugha (Sources of current stable release)
      • trunk (Sources of SVN trunk)
    • Builds (CMake build directories)
      • Cthugha (Standard build of current stable release)
      • trunk (Standard build of SVN trunk)
      • trunk.static (Static build of SVN trunk)

Preparing the Environment

Running CMake

For this step, you need to have downloaded and installed CMake. If you need instructions on that, look here: Getting Started With CMake
Run CMake to prepare your build directory. Instructions are at the page linked above, but in quintessence: Start cmake-gui, then at the top select the build and source directory you want to use and click on "Configure". You will then be asked about the build system you want to generate; the default should be fine for most people.

Ogre offers a variety of build options you can configure with the help of cmake-gui. The default options provide a sensible default which will give you a build similar to the official SDK releases. Following is a list of available Ogre build options and their effect on the build process.

  • OGRE_BUILD_COMPONENT_PAGING - If enabled, Ogre's optional paging component will be built.
  • OGRE_BUILD_COMPONENT_PROPERTY - If enabled, Ogre's optional property component will be built.
  • OGRE_BUILD_COMPONENT_TERRAIN - If enabled, Ogre's optional paging terrain component will be built.
  • OGRE_BUILD_COMPONENT_OVERLAY - If enabled, Ogre's optional overlay component will be built.
  • OGRE_BUILD_COMPONENT_VOLUME - If enabled, Ogre's optional volume rendering component will be built.
  • OGRE_BUILD_COMPONENT_RTSHADERSYSTEM - If enabled, Ogre's optional runtime shader system component will be built.
  • OGRE_BUILD_PLATFORM_APPLE_IOS - If enabled, Ogre will be built for the iOS platform
  • OGRE_BUILD_PLATFORM_ANDROID - If enabled, Ogre will be built for the Android platform
  • OGRE_BUILD_PLATFORM_WINRT - If enabled, Ogre will be built for the Windows RT platform
  • OGRE_BUILD_PLATFORM_NACL - If enabled, Ogre will be built for Google's Native Client platform
  • OGRE_BUILD_PLUGIN_BSP - If enabled, the BSP SceneManager plugin will be built.
  • OGRE_BUILD_PLUGIN_CG - If enabled, the Cg ProgramManager plugin will be built. This requires that Nvidia's Cg compiler library was found by CMake.
  • OGRE_BUILD_PLUGIN_OCTREE - If enabled, the Octree SceneManager and Terrain SceneManager plugin will be built.
  • OGRE_BUILD_PLUGIN_PCZ - If enabled, the Portal Connected Zone SceneManager plugin will be built.
  • OGRE_BUILD_PLUGIN_PFX - If enabled, the ParticleFX plugin will be built.
  • OGRE_BUILD_RENDERSYSTEM_GL - If enabled, the OpenGL RenderSystem will be built.
  • OGRE_BUILD_RENDERSYSTEM_GL3Plus - If enabled, the OpenGL 3+ RenderSystem will be built.
  • OGRE_BUILD_RENDERSYSTEM_GLES - If enabled, the OpenGL ES RenderSystem will be built. This requires that CMake needs to have found the Open GL ES SDK.
  • OGRE_BUILD_RENDERSYSTEM_GLES2 - If enabled, the OpenGL ES 2 RenderSystem will be built. This requires that CMake needs to have found the Open GL ES SDK.
  • OGRE_BUILD_RENDERSYSTEM_D3D9 - If enabled, the Direct3D9 RenderSystem will be built. This requires a Windows platform, and CMake needs to have found the DirectX SDK.
  • OGRE_BUILD_RENDERSYSTEM_D3D11 - If enabled, the Direct3D11 RenderSystem will be built. This requires a Windows platform and a sufficiently recent DirectX SDK.
  • OGRE_BUILD_SAMPLES - If enabled, Ogre's samples will be built. All samples need the OIS library, so this option requires that OIS has been found by CMake. Additionally, some samples depend on CEGUI or specific plugins and might be skipped if those dependencies are not met.
  • OGRE_BUILD_TESTS - If enabled, Ogre library test cases will be built. This requires that the cppunit library was found by CMake.
  • OGRE_BUILD_TOOLS - If enabled, this will build Ogre's command line tools (MeshUpgrader and [[OgreXmlConverter|XMLConverter]]).
  • OGRE_CONFIG_ALLOCATOR - This option determines the allocator to use for Ogre's memory allocations. A value of 1 will use standard STL allocators, the default value 2 selects an allocator based on nedmalloc. The value 3 is needed for a user-provided allocator.
  • OGRE_CONFIG_CONTAINERS_USE_CUSTOM_ALLOCATOR - Enabling this option has Ogre use the custom allocator for internally used STL containers.
  • OGRE_CONFIG_DISABLE_DDS - If this option is set, then Ogre's DDS image codec will not be built.
  • OGRE_CONFIG_DISABLE_FREEIMAGE - If this option is set, the FreeImage image codecs will not be built. If this option is not set, then the FreeImage library needs to have been found by CMake.
  • OGRE_CONFIG_DOUBLE - Enabling this option makes Ogre use the double type instead of float.
  • OGRE_CONFIG_MEMTRACK_DEBUG - Setting this option enables Ogre's memory tracker in debug mode.
  • OGRE_CONFIG_MEMTRACK_RELEASE - Setting this option enables Ogre's memory tracker in release mode.
  • OGRE_CONFIG_NEW_COMPILERS - If enabled, Ogre will use the new script compilers. This is the default.
  • OGRE_CONFIG_STRING_USE_CUSTOM_ALLOCATOR - If enabled, Ogre::String will use the custom allocator. Be aware that in this case Ogre::String will be incompatible with std::string.
  • OGRE_CONFIG_THREADS - This setting determines Ogre's threading support. A value of 0 disables threading support. A setting of 1 enables full background resource loading, whereas a value of 2 enables only background resource preparation. Setting this to 1 does not work under Linux, using only modes 0 and 2 is recommended.
  • OGRE_DEPENDENCIES_DIR - Contains the directory where Ogre's dependencies can be found. This setting can be used to help CMake locate dependencies; it is primarily important when using prebuilt dependencies for Windows / Mac platforms.
  • OGRE_FULL_RPATH - If enabled, then on Unix platforms installed program files will contain the full RPATH needed to run them. If disabled, only partial RPATH needed for the PCZ SceneManager is included. You can disable even that part by enabling CMAKE_SKIP_RPATH.
  • OGRE_INSTALL_DOCS - If enabled, Ogre documentation (manual and API reference) will be installed.
  • OGRE_INSTALL_MEDIA - If enabled, Ogre's sample media files will be installed.
  • OGRE_INSTALL_PLUGIN_HEADERS - If enabled, the headers of Ogre's plugins will be installed. Usually plugins are meant to be usable without explicitly linking to them, therefore headers are usually not required. There are, however, exceptional cases where you might need them.
  • OGRE_INSTALL_SAMPLES - If enabled, Ogre's samples will be installed. This requires that samples be built in the first place.
  • OGRE_INSTALL_SAMPLES_SOURCE - If enabled, the source code of Ogre's samples will be installed. Primarily targeted for official SDK packages.
  • OGRE_INSTALL_TOOLS - If enabled, the command line tools will be installed. This requires that they be built in the first place.
  • OGRE_STANDALONE_BUILD - An experimental option targeted for the Windows platform to pregenerate Visual Studio project files; intended for official SDK packages.
  • OGRE_STATIC - Enabling this option will build Ogre and all of its components and plugins (as far as they are enabled) as static libraries.
  • OGRE_CONFIG_STATIC_LINK_CRT - Enabling this option will build Ogre with statically linked MS CRT dlls (msvcrt). This option is only available when compiling with the MS compiler. The default value is false for this option. Note: The OGRE dependencies will also need to be compiled with statically linked CRT - else the linker will fail with "...error LNK2005: _xxxx already defined in...".
  • OGRE_LIB_DIRECTORY - You can use this option to select the library installation directory (such as /usr/lib64 for 64 bit architectures)


Choose options according to your wishes. In particular, disabling features you don't need will apparently reduce your compile time. Once you're satisfied, hit 'Configure' again in cmake-gui, then select 'Generate'. This will create a customised build system in your build directory, according to the options you just selected.

Configuring for iOS


Of course you will need to have downloaded and installed CMake.

After that, head over to http://sourceforge.net/projects/ogre/files/ and download the latest iOS dependencies package. Once it has finished downloading, double-click on the disc image to mount it. Copy the iOSDependencies folder to the root of the Ogre source tree. It should reside alongside folders such as OgreMain, Samples, Tests, PlugIns, etc.

The best way to configure for iOS is using Terminal. 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_APPLE_IOS=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 iOS 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.

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.

Building and Installing


If you are installing on an iPod / iPhone, see the first troubleshooting link:

Creating resource group Essential
Added resource location '/Users/taehyungkim/Documents/ogre_src_v1-7-1-2/Samples/Media/thumbnails' of type 'FileSystem' to resource group 'Essential'
Current language: auto; currently c++
(gdb) continue

An exception has occurred: OGRE EXCEPTION(7:InternalErrorException): <path>/Media/packs/SdkTrays.zip - error whilst opening archive: Unable to read zip file. in ZipArchive::checkZzipError at <path>/OgreMain/src/OgreZip.cpp (line 280)


Looks like your app can't read the zip file. My guess is that your resources.cfg contains absolute paths to the resources and it's trying to load files that are outside the application bundle.

Change it to use absolute paths instead, like this:

Code: Select all

Zip=Media/packs/SdkTrays.zip

Troubleshooting

http://www.ogre3d.org/forums/viewtopic.php?f=2&t=58579

<HR>
Creative Commons Copyright -- Some rights reserved.


THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

  • "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
  • "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
  • "Licensor" means the individual or entity that offers the Work under the terms of this License.
  • "Original Author" means the individual or entity who created the Work.
  • "Work" means the copyrightable work of authorship offered under the terms of this License.
  • "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
  • "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.

2. Fair Use Rights

Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant

Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

  • to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
  • to create and reproduce Derivative Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
  • For the avoidance of doubt, where the work is a musical composition:
    • Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
    • Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
    • Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).


The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.

4. Restrictions

The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

  • You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
  • You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
  • If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.

5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.

6. Limitation on Liability.

EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. Termination

  • This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
  • Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneous

  • Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
  • Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
  • If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
  • No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
  • This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.