Skip to main content

History: Building Ogre V2 with CMake

Source of version: 12

Copy to clipboard
            {BOX(width="100%",class="Layout_box9")}{SPLIT(colsize=10%|70%)}{IMG(src="img/wiki_up/CMake.png",imalign="left",link="Building Ogre V2 with CMake",title="Building Ogre V2 with CMake")}{IMG}
---
{DIV(class="bigBold")}((Building Ogre V2 with CMake)){DIV}
This section explains how to use CMake to build Ogre from source.
{SPLIT}{BOX}
!!Getting the Ogre Sources
First you need to download the Ogre sources. You can get them from [https://bitbucket.org/sinbad/ogre]. 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 [https://bitbucket.org/cabalistic/ogredeps|'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(__R__apidjson_INCLUDE_DIR "${rapidjson_SOURCE_DIR}" CACHE PATH "" FORCE)'' (watch the capital __R__).
* 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.

{IMG(src="tiki-download_file.php?fileId=2303&display",imalign="center")}{IMG}

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\SDLmain\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\SDL\x64\Release\SDL2.lib
{DIV(class="Bloody_box1")}__LoggedInUser__ = Current user{DIV}

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__ ...
* __CMAKE_BUILD_TYPE__ ...
* __CMAKE_CONFIGURATION_TYPES__ ...
* __CMAKE_INSTALL_PREFIX__ ...
* __DirectX_DINPUT8_LIBRARY__ Refers to the input library of DirectX 9 (user for SDL2)
* __EXECUTABLE_OUTPUT_PATH__ ...
* __LIBRARY_OUTPUT_PATH__ ...
* __OGREDEPS_BUILD_AMD_QBS__ ...
* __OGREDEPS_BUILD_CG__ ...
* __OGREDEPS_BUILD_FREEIMAGE__ ...
* __OGREDEPS_BUILD_FREETYPE__ ...
* __OGREDEPS_BUILD_NVIDIA_NVAPI__ ...
* __OGREDEPS_BUILD_OIS__ ...
* __OGREDEPS_BUILD_RAPIDJSON__ ...
* __OGREDEPS_BUILD_SDL2__ ...
* __OGREDEPS_BUILD_ZLIB__ ...
* __OGREDEPS_BUILD_ZZIPLIB__ ...
* __OGREDEPS_INSTALL_DEV__ ...
* __OGRE_ASSERT_MODE__ ...
* __OGRE_BUILD_COMPONENT_HLMS_PBS__ ...
* __OGRE_BUILD_COMPONENT_HLMS_PBS_MOBILE__ ...
* __OGRE_BUILD_COMPONENT_HLMS_UNLIT__ ...
* __OGRE_BUILD_COMPONENT_HLMS_UNLIT_MOBILE__ ...
* __OGRE_BUILD_COMPONENT_MESHLODGENERATOR__ ...
* __OGRE_BUILD_COMPONENT_OVERLAY__ ...
* __OGRE_BUILD_COMPONENT_PAGING__ ...
* __OGRE_BUILD_COMPONENT_RTSHADERSYSTEM__ Realtime shader system; 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]
* __OGRE_BUILD_PLATFORM_NACL__ ...
* __OGRE_BUILD_PLUGIN_CG__ ...
* __OGRE_BUILD_PLUGIN_PFX__ ...
* __OGRE_BUILD_RENDERSYSTEM_3D11__ ...
* __OGRE_BUILD_RENDERSYSTEM_GL3PLUS__ ...
* __OGRE_BUILD_RENDERSYSTEM_GLES__ ...
* __OGRE_BUILD_SAMPLES__ Obsolete for Ogre V2+
* __OGRE_BUILD_SAMPLES2__ Ogre V2+ tutorial and samples
* __OGRE_BUILD_TESTS__ ...
* __OGRE_BUILD_TOOLS__ ...
* __OGRE_CONFIG_ENABLE_JSON__ ...
* __OGRE_CONFIG_ENABLE_QUAD_BUFFER_STEREO__ ...
* __OGRE_CONFIG_THREADS__ ...
* __OGRE_CONFIG_THREAD_PROVIDER__ ...
* __OGRE_CONFIG_COPY_DEPENDENCIES__ ...
* __OGRE_CONFIG_DEPENDENCIES_DIR__ ...
* __OGRE_INSTALL_DEPENDENCIES__ ...
* __OGRE_INSTALL_DOCS__ ...
* __OGRE_INSTALL_PDB__ ...
* __OGRE_INSTALL_SAMPLES__ ...
* __OGRE_INSTALL_TOOLS__ ...
* __OGRE_INSTALL_VSPROPS__ ...
* __OGRE_LEGACY_ANIMATION__ ...
* __OGRE_RESTRICT_ALIASSING__ ...
* __OGRE_SIMD_NEON__ ...
* __OGRE_SIMD_SSE2__ ...
* __OGRE_STATIC__ ...
* __OGRE_UNITY_BUILD__ ...
* __OGRE_UNITY_FILES_PER_UNIT__ ...
* __SDL2MAIN_LIBRARY__ Location (path) of SDL main library
* __SDL2_INCLUDE_DIR__ Location (path) of SDL header files
* __SDL2_LIBRARY__ Location (path) of SDL library


Select the other options (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).
Hit the "Configure" button until all red lines are gone. After that, push "Generate", to generate your project.


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.

!!!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:
{CODE(wrap="1", colors="bash")}  mkdir build && cd build{CODE}
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:
{CODE(wrap="1", colors="bash")}  cmake -D OGRE_BUILD_PLATFORM_APPLE_IOS=1 -G Xcode ..{CODE}
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]
        

History

Information Version
Tue 06 of Jun, 2023 14:23 GMT-0000 dark_sylinc 37
Fri 27 of Jan, 2017 17:42 GMT-0000 spookyboo 36
Fri 27 of Jan, 2017 17:24 GMT-0000 spookyboo 35
Fri 27 of Jan, 2017 16:42 GMT-0000 spookyboo 34
Fri 27 of Jan, 2017 16:18 GMT-0000 spookyboo 33
Fri 27 of Jan, 2017 16:03 GMT-0000 spookyboo 32
Fri 30 of Dec, 2016 14:05 GMT-0000 spookyboo 31
Thu 29 of Dec, 2016 23:31 GMT-0000 spookyboo 30
Thu 29 of Dec, 2016 23:30 GMT-0000 spookyboo 29
Thu 29 of Dec, 2016 23:30 GMT-0000 spookyboo 28
Thu 29 of Dec, 2016 22:28 GMT-0000 spookyboo 27
Thu 29 of Dec, 2016 22:14 GMT-0000 spookyboo 26
Thu 29 of Dec, 2016 21:59 GMT-0000 spookyboo 25
Thu 29 of Dec, 2016 21:52 GMT-0000 spookyboo 24
Thu 29 of Dec, 2016 20:17 GMT-0000 spookyboo 23
Thu 29 of Dec, 2016 20:16 GMT-0000 spookyboo 22
Thu 29 of Dec, 2016 20:15 GMT-0000 spookyboo 21
Thu 29 of Dec, 2016 20:13 GMT-0000 spookyboo 20
Thu 29 of Dec, 2016 20:08 GMT-0000 spookyboo 19
Thu 29 of Dec, 2016 20:08 GMT-0000 spookyboo 18
Thu 29 of Dec, 2016 20:06 GMT-0000 spookyboo 17
Thu 29 of Dec, 2016 20:01 GMT-0000 spookyboo 16
Thu 29 of Dec, 2016 19:54 GMT-0000 spookyboo 15
Thu 29 of Dec, 2016 19:53 GMT-0000 spookyboo 14
Thu 29 of Dec, 2016 19:40 GMT-0000 spookyboo 13
  • «
  • 1 (current)
  • 2