History: Building Ogre V2 with CMake
Preview of version: 12
- «
- »
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 '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)
- ogre2.1 (Ogre branch 2.1)
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).
- 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\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
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:
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
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