Building Ogre V2 with CMake        

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


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


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_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
  • OGRE_BUILD_MSVC_ZM Specify memory allocation limit for Visual Studio; see; 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_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_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


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.