This is a cmake script for building the Ogre Wiki Tutorial Framework, but it can easily be adapted for your own projects.
Works for Visual Studio, MinGW, and the GCC toolchain.
Table of contents
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
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.
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.
Get the Ogre Wiki Tutorial Framework and put the four files in a directory:
- CMakeLists.txt (see below)
Download one of these archives and unpack it into the ogreapp directory:
This CMake script assumes the following:
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.
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.
- Open CMake-Gui, choose your source directory ('ogreapp') and a build directory ('ogreapp_build').
- Click 'Configure', choose a generator.
- Click 'Configure' again if CMake ran without fatal errors.
- Click 'Generate'.
- 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.
- Open the 'OgreApp' solution and build the 'BUILD_ALL' project.
- Build the 'INSTALL' project - you only need to build this once to copy the Ogre DLLs, configuration files and media over.
- Open a command prompt and issue the command: mingw32-make
- Install the Ogre files by doing a mingw32-make install
- In a console, issue the command: make
- 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
- 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.
- 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!
- 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.