Image

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

OUTDATE NOTICE


This guide seems to have gotten old.

You can see the official manual instructions which are kept up to date.

Getting the Ogre Sources

First you need to download the Ogre sources. You can get them from http://github.com/OGRECave/ogre-next. Make sure you get the correct branch. Ogre V2 starts with branch '2-1' (use a tool like Sourcetree to pull this branch from Bitbucket).
You also need the 'dependencies' pack. In most cases the 'default' branch of the 'dependencies' pack will suffice. Make sure you copy the whole 'ogredeps' directory in the Ogre root (on the same level as 'OgreMain') and rename it to 'Dependencies' (somewhere in the CMake scripts this name is needed).

A pull from Bitbucket 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 all Ogre versions, somewhere on your disk)
    • ogre2.1 (Ogre branch 2.1)
      • .hg (used by Mercurial)
      • CMake
      • Components
      • Docs
      • Dependencies (copied 'ogredeps' structure and renamed it to Dependencies)
      • OgreMain
      • Other
      • PlugIns
      • RenderSystems
      • Samples
      • Scripts
      • SDK
      • Tests
      • Tools
      • VCBuild (Visual Studio build)
      • VCBuild.static (Visual Studio static build)

Preparing the Environment

Some adjustments

Running CMake results in errors. Somehow, it cannot find RapidJson (used for loading and saving HLMS materials) and SDL2 (used for tutorials and samples). Make the following changes:

  • Change in Dependencies\src\rapidjson\CMakeLists.txt the line set(rapidjson_INCLUDE_DIR "${rapidjson_SOURCE_DIR}" CACHE PATH "" FORCE) into set(Rapidjson_INCLUDE_DIR "${rapidjson_SOURCE_DIR}" CACHE PATH "" FORCE) (watch the capital R).
  • Copy the complete directory Dependencies\src\rapidjson\include to the same level and rename it to Dependencies\src\rapidjson\rapidjson, because the Ogre files are referring to that level, for example #include "rapidjson/document.h" in file OgreHlmsJson.cpp.
  • For SDL2, currently the easiest option is to compile SDL2 separately (Dependencies\src\SDL2\CMakeLists.txt needs some work). E.g. if you use Visual Studio, there is a separate .sln solution in src\SDL2\VisualC. If you build it, the paths for SDL2MAIN_LIBRARY, SDL2_INCLUDE_DIR and SDL2_LIBRARY_TEMP can be set manually (see next paragraph).

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". Choose the compiler of choice.

Image

CMake returns with an error message. Ignore it for now and hit "Configure" again. Note, that SDL2 couldn't be located. The CMake properties SDL2MAIN_LIBRARY, SDL2_INCLUDE_DIR and SDL2_LIBRARY_TEMP must be manually filled (do not forget to compile SDL2 separately). The settings below refer to a 64bit build on Windows:

  • SDL2MAIN_LIBRARY = C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\SDL2\VisualC\x64\Release\SDL2main.lib
  • SDL2_INCLUDE_DIR = C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\SDL2\include
  • SDL2_LIBRARY_TEMP = C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\SDL2\VisualC\x64\Release\SDL2.lib
LoggedInUser = Current user


Ogre offers a variety of build options you can configure with the help of cmake-gui. The default options provide a sensible default. Following is a list of available Ogre build options and their effect on the build process.

  • CMAKE_BACKWARDS_COMPATIBILITY For backwards compatibility, what version of CMake commands and syntax should this version of CMake try to support.
  • CMAKE_BUILD_TYPE Choose the type of build, options are: Debug, Release.
  • CMAKE_CONFIGURATION_TYPES Semicolon separated list of supported configuration types, only supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored.
  • CMAKE_INSTALL_PREFIX OGRE install prefix.
  • DirectX_DINPUT8_LIBRARY Refers to the input library of DirectX 9 (user for SDL2).
  • EXECUTABLE_OUTPUT_PATH Single output directory for building all executables.
  • LIBRARY_OUTPUT_PATH Single output directory for building all libraries.
  • OGREDEPS_BUILD_AMD_QBS Build AMD Quad Buffer SDK dependency
  • OGREDEPS_BUILD_CG Setting to build CG
  • OGREDEPS_BUILD_FREEIMAGE Setting to build freeimage
  • OGREDEPS_BUILD_FREETYPE Setting to build freetype
  • OGREDEPS_BUILD_NVIDIA_NVAPI Build NVIDIA NVAPI dependency
  • OGREDEPS_BUILD_OIS Setting to build OIS; this has become obsolete for Ogre V2, because keyboard input (tutorials and samples) is done by means of SDL2.
  • OGREDEPS_BUILD_RAPIDJSON Setting to use RapidJson; Enable it when you want to save and load HLMS materials.
  • OGREDEPS_BUILD_SDL2 Setting to build OIS; this is needed for keyboard input (tutorials and samples).
  • OGREDEPS_BUILD_ZLIB Setting to build zlib
  • OGREDEPS_BUILD_ZZIPLIB Setting to build zziplib
  • OGREDEPS_INSTALL_DEV Install development headers and libraries
  • OGRE_ASSERT_MODE Enable Ogre asserts and exceptions. Possible values:
    • 0 - Standard asserts in debug builds, nothing in release builds.
    • 1 - Standard asserts in debug builds, exceptions in release builds.
    • 2 - Exceptions in debug builds, exceptions in release builds.
  • OGRE_BUILD_COMPONENT_HLMS_PBS Build the PBS (Physically Based Shaders) HLMS (High Language Material Shader).
  • OGRE_BUILD_COMPONENT_HLMS_PBS_MOBILE Build option for PBS shaders (Physically Based Shaders) using HLMS (High Language Material Shader) - for mobile devices.
  • OGRE_BUILD_COMPONENT_HLMS_UNLIT Build option for Unlit shaders using HLMS.
  • OGRE_BUILD_COMPONENT_HLMS_UNLIT_MOBILE Build option for Unlit shaders using HLMS - for mobile devices.
  • OGRE_BUILD_COMPONENT_MESHLODGENERATOR If enabled, Ogre's optional meshlod generator component will be built.
  • OGRE_BUILD_COMPONENT_OVERLAY If enabled, Ogre's optional overlay component will be built.
  • OGRE_BUILD_COMPONENT_PAGING If enabled, Ogre's optional paging component will be built.
  • OGRE_BUILD_COMPONENT_RTSHADERSYSTEM If enabled, Ogre's optional runtime shader system component will be built; this component was introduced as a replacement of the fixed function pipeline, but has become obsolete in Ogre V2.
  • OGRE_BUILD_MSVC_MP Multi processor build flag for Visual Studio; see https://msdn.microsoft.com/en-us/library/bb385193.aspx
  • OGRE_BUILD_MSVC_ZM Specify memory allocation limit for Visual Studio; see https://msdn.microsoft.com/en-us/library/bdscwf1c.aspx; Add /Zm256 compiler option to Visual Studio to fix PCH errors
  • OGRE_BUILD_PLATFORM_NACL If enabled, Ogre will be built for Google's Native Client platform
  • 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_PFX If enabled, the ParticleFX plugin will be built.
  • OGRE_BUILD_RENDERSYSTEM_3D11 If enabled, the Direct3D11 RenderSystem will be built. This requires a Windows platform and a sufficiently recent DirectX SDK.
  • 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_SAMPLES Obsolete for Ogre V2
  • OGRE_BUILD_SAMPLES2 If enabled, Ogre V2 tutorial and samples will be built.
  • 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_ENABLE_JSON If enabled, Ogre is capable to save and load HLMS materials (and other types ) in Json format.
  • OGRE_CONFIG_ENABLE_QUAD_BUFFER_STEREO Enable stereoscopic 3D support
  • 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_CONFIG_THREAD_PROVIDER Determines which library is used for threading; you must have a good reason to use a threading library. Using this is considered 'old style' in Ogre and not recommended in Ogre 2.1 and beyond.
    • boost - Boost thread library.
    • poco - (Poco thread library.
    • tbb - ThreadingBuildingBlocks library.
    • stl - STL thread library (requires compiler support).
    • none
  • OGRE_CONFIG_COPY_DEPENDENCIES
  • OGRE_CONFIG_DEPENDENCIES_DIR
  • OGRE_INSTALL_DEPENDENCIES Install dependency libs needed for samples.
  • OGRE_INSTALL_DOCS Install documentation.
  • OGRE_INSTALL_PDB Install debug pdb files.
  • OGRE_INSTALL_SAMPLES Install Ogre demos.
  • OGRE_INSTALL_TOOLS Install Ogre tools.
  • OGRE_INSTALL_VSPROPS Install Visual Studio Property Page.
  • OGRE_LEGACY_ANIMATION Use the skeletal animation from Ogre 1.x. It's much slower, but the new system is still experimental.
  • OGRE_RESTRICT_ALIASSING
  • OGRE_SIMD_NEON Enable SIMD (Include NEON files).
  • OGRE_SIMD_SSE2 Enable SIMD (Include SSE2 files).
  • OGRE_STATIC Static build
  • OGRE_UNITY_BUILD Enable unity build for Ogre.
  • OGRE_UNITY_FILES_PER_UNIT Number of files per compilation unit in Unity build.
  • SDL2MAIN_LIBRARY Location (path) of SDL main library
  • SDL2_INCLUDE_DIR Location (path) of SDL header files
  • SDL2_LIBRARY Location (path) of SDL library


Choose options according to your wishes; e.g. OGRE_BUILD_SAMPLES2 is not checked; check it if you want to build the Ogre V2 samples. OGRE_BUILD_SAMPLES is unchecked. Leave it this way, because they refer to samples of previous Ogre version. In particular, disabling features you don't need will apparently reduce your compile time. Once you're satisfied, hit 'Configure' again in cmake-gui until all red lines are disappeard, then select 'Generate'. This will create a customised build system in your build directory, according to the options you just selected.

Configure and compile

Image

Done Visual Studio

Open the file OGRE.sln in the path you defined in the CMake gui ("Where to build the binaries") and choose the option "Build Solution" from the Visual Studio menu.
The binaries are build in the bin\release directory.

<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.