Skip to main content

History: Building Your Projects With CMake

Preview of version: 77

Image

This is an introduction to using cmake to build your own Ogre projects. For more detailed information about cmake, refer to the official site.

IMPORTANT: These instructions are meant to be used with old releases of Ogre. For Ogre 1.10+, rather use The Tutorials.

Introduction

This is a cmake script for building the Ogre Wiki Tutorial Framework, but it can easily be adapted for your own projects.

Done

Works for Visual Studio, MinGW, and the GCC toolchain.

Prerequisites

Be sure to visit the Prerequisites page!

Note for Windows:
If you don't have Boost installed, you want to set the environment variable BOOST_ROOT to OGRE_HOME/boost


What It Does

The CMake script will configure your project to output the executable into 'BUILD_DIRECTORY/dist/bin', either by post-build copy or by setting the output path directly.
The INSTALL project/target will copy plugins.cfg and resources.cfg to the bin directory, and on Windows it will additionally copy the Ogre DLLs and the Media directory as well (to 'BUILD_DIRECTORY/Media').
Normally, you don't need to build the install target more than once, or whenever Ogre itself changes.

If you don't want, or need that behavior, either don't build INSTALL, or modify it to suit your needs.


What You Need

Convenient All-In-One Download

No such attachment on this page
No such attachment on this page (updated for Ogre 1.9)
Just download and un-archive, and you're all set. ๐Ÿ˜‰
The download contains a copy of the tutorial framework, the dist directory and the CMake script.
You can also check this github project, which is compatible with Ogre 1.7, 1.8 and 1.9. It also include continuous integration builds on Travis and Gitlab CI. The project is under MIT license and contributions are welcome.

Ogre Wiki Tutorial Framework

Get the Ogre Wiki Tutorial Framework and put the four files in a directory:

  • ogreapp
    • CMakeLists.txt (see below)
    • BaseApplication.h
    • BaseApplication.cpp
    • TutorialApplication.h
    • TutorialApplication.cpp

Dist archive

Download one of these archives and unpack it into the ogreapp directory:
No such attachment on this page | No such attachment on this page

CMakeLists.txt

Info Red

This CMake script assumes the following:

  • Windows: the environment variable OGRE_HOME is set to point to the root directory of your Ogre SDK.
  • Linux: Ogre is installed in the standard path: /usr/local.
  • You're using the 1.7.2 SDK. In 1.7.2 the OIS.dll was renamed to libOIS.dll. As of 1.7.2 it is also necessary to copy the boost dll's into the bin directory because they're no longer statically linked. You can remove that part of the script (at the bottom) if you're using 1.7.1 (but it shouldn't do any harm if you leave it).

CMakeLists

Replace OgreApp with any name you want.
CMAKE_MODULE_PATH points to where you installed the Ogre3D cmake modules.
OGRE_SAMPLES_INCLUDEPATH points to where you installed the Ogre3D Samples framework include directory.
This usually happens when you run make install on Ogre.

How To Use It

After having created your OgreApp source directory, and populated it with the four files from the Ogre Wiki Tutorial Framework and the CMakeLists.txt file, plus the 'dist' directory, you are now ready to build it using CMake.

  1. Open CMake-Gui, choose your source directory ('ogreapp') and a build directory ('ogreapp_build').
  2. Click 'Configure', choose a generator.
  3. Click 'Configure' again if CMake ran without fatal errors.
  4. Click 'Generate'.
  5. Navigate to your 'ogreapp_build' directory.

If you don't see anything in the status window, switch to 'advanced view'.

What you should do next depends on what generator you're using.

Visual Studio

  1. Open the 'OgreApp' solution and build the 'BUILD_ALL' project.
  2. Build the 'INSTALL' project - you only need to build this once to copy the Ogre DLLs, configuration files and media over.

MinGW

  1. Open a command prompt and issue the command: mingw32-make
  2. Install the Ogre files by doing a mingw32-make install

GCC on Linux

  1. In a console, issue the command: make
  2. You should see the make command looking for the parts of the build that are required (Ogre (obviously:)), OIS, boost, etc..) Then the compilation progress indicators
  3. Now, issue the command: make install Don't worry: it's a 'fake' install, it's only local. What it does is copy the 'dist' directory over to your build directory.
  4. Run the "OgreApp" bin and you should see a blank screen with some OgreSDK info overlays. If you've gotten this far, your build process works!
  5. If you get errors, you might need to copy the plugins.cfg from /usr/share/OGRE to your dist directory (use the one in your source directory, not the one in the build directory):
    cp /usr/share/OGRE/plugins.cfg ~/programming/ogreapp/dist/bin/plugins.cfg


If you're a Linux user, be sure to check out Setting Up An Application - Linux for ways to import the CMake script into NetBeans, QtCreator, KDevelop and other development environments.

Happy coding! ๐Ÿ˜Š

History

Information Version
Sat 28 of Dec, 2024 15:43 GMT-0000 paroj 80
Thu 08 of Apr, 2021 21:22 GMT-0000 paroj 79
Thu 08 of Apr, 2021 21:22 GMT-0000 paroj 78
Thu 08 of Apr, 2021 21:20 GMT-0000 paroj 77
Sun 18 of Jun, 2017 11:18 GMT-0000 paroj 76
Fri 20 of Jan, 2017 01:47 GMT-0000 paroj 75
Sun 24 of Jan, 2016 13:33 GMT-0000 azmeuk 74
Sun 10 of Jan, 2016 16:35 GMT-0000 azmeuk 73
Sat 07 of Nov, 2015 11:45 GMT-0000 azmeuk 72
Sat 07 of Nov, 2015 11:44 GMT-0000 azmeuk 71
Thu 15 of Oct, 2015 19:02 GMT-0000 Sauermann Added v1.10 Windows framework 70
Tue 31 of Mar, 2015 06:09 GMT-0000 kabbotta 69
Tue 31 of Mar, 2015 05:59 GMT-0000 kabbotta 68
Tue 31 of Mar, 2015 05:56 GMT-0000 kabbotta 67
Tue 31 of Mar, 2015 05:54 GMT-0000 kabbotta 66
Tue 31 of Mar, 2015 05:54 GMT-0000 kabbotta 65
Tue 31 of Mar, 2015 05:53 GMT-0000 kabbotta 64
Tue 31 of Mar, 2015 05:53 GMT-0000 kabbotta 63
Fri 13 of Dec, 2013 05:57 GMT-0000 c6burns 62
Tue 10 of Dec, 2013 19:10 GMT-0000 c6burns added zip with changes for 1.9 61
Tue 13 of Nov, 2012 22:18 GMT-0000 jazztickets boost path was wrong for ogre 1.81 60
Thu 01 of Dec, 2011 21:48 GMT-0000 TcR1oo565 59
Tue 02 of Aug, 2011 14:07 GMT-0000 jacmoe 58
Sun 31 of Jul, 2011 23:34 GMT-0000 jacmoe 57
Thu 10 of Feb, 2011 10:53 GMT-0000 jacmoe 56