OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Building Your Projects With CMake
View page
Source of version: 79
(current)
{BOX(width="100%",class="Layout_box9")} {SPLIT(colsize=10%|70%)} {IMG(src="img/wiki_up/Libraries.png",imalign="left",link="Building Your Projects With CMake",title="Building Your Projects With CMake")}{IMG} --- {DIV(class="bigBold")}((Building Your Projects With CMake)){DIV} This is an introduction to using cmake to build your own Ogre projects. For more detailed information about cmake, refer to the [http://www.cmake.org|official site]. {SPLIT}{BOX} {DIV(class="achtung")}__IMPORTANT:__ These instructions are meant to be used with old releases of Ogre. For Ogre 1.10+, rather use [https://ogrecave.github.io/ogre/api/latest/setup.html|The Tutorials].{DIV} !Introduction This is a cmake script for building the ((Ogre Wiki Tutorial Framework)), but it can easily be adapted for your own projects. {DIV(class="Layout_box6")}%done% Works for Visual Studio, MinGW, and the GCC toolchain. {DIV} {maketoc} !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 {MONO()}BOOST_ROOT{MONO} to {MONO()}OGRE_HOME/boost{MONO} --- !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 {ATTACH(id="141",icon="1",showdesc="0")}{ATTACH} {ATTACH(id="186",icon="1",showdesc="0")}{ATTACH} (updated for Ogre 1.9) Just download and un-archive, and you're all set. (:wink:) The download contains a copy of the tutorial framework, the dist directory and the CMake script. You can also check [https://github.com/ogre3d/clean-project|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 {MONO()}ogreapp{MONO} directory: {ATTACH(id="128",icon="1",showdesc="1")}{ATTACH} | {ATTACH(id="135",icon="1",showdesc="1")}{ATTACH} !!CMakeLists.txt {TRANSCLUDE(page="infodiv")}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). {TRANSCLUDE} ((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. # 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. !!Visual Studio # 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. !!MinGW # Open a command prompt and issue the command: {MONO()}mingw32-make{MONO} # Install the Ogre files by doing a {MONO()}mingw32-make install{MONO} !!GCC on Linux # In a console, issue the command: {MONO()}make{MONO} # 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: {MONO()}make install{MONO} 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): +{MONO()}cp /usr/share/OGRE/plugins.cfg ~/programming/ogreapp/dist/bin/plugins.cfg{MONO} 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! :)
Search by Tags
Search Wiki by Freetags
Latest Changes
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
...more
Search
Find
Advanced
Search Help
Online Users
71 online users