First things first: grab the latest ogre version. At the time of this post, it is the 1.9 release, and you can find its repository here. Note: you want to download the 1.9 version using the tag download feature from Bitbucket; do not simply download the master branch. After that, extract it, create a build directory inside its directory, cd into it, and do a
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.lib -DOGRE_INSTALL_SAMPLES=TRUE -DOGRE_INSTALL_DOCS=TRUE -DOGRE_INSTALL_SAMPLES_SOURCE=TRUE -DCMAKE_BUILD_TYPE=Release
This is a pretty much standard cmake build. If your system is missing some of its dependencies, you will be warned and you should install them. Then:
make OgreDoc install
Now it is a good moment to read xkcd.
The usual difference here is that we don’t do a normal make install. Why? Because we don’t want our stuff ending up on /usr/local. Instead, we want it somewhere where we have full access as a normal (non-root) user — in this example, $HOME/.lib/ogre.
Now, head to the basic 1 page of the ogre wiki and download its example. You should try to build it, but take care to change all ogre3d references from /usr/local to your new install directory ($HOME/.lib/ogre). Yeah, that’s it.
Note: if the basic 1 download doesn’t come with a CMakeLists.txt file, you can download it from here (clean ogre cmake project). You can use it verbatim; just put it in the same directory as the basic 1 files and — again — change any references to /usr/local to your new install directory. Also, copy the dist/ directory too (if it is missing from the Basic 1 project),
I’ll add a small observation: in the case cmake complains about pkg-config, try adding this line to the top of your CMakeLists.txt (but after the project version):
Credits: the build style I adopted here was derived from the Ogre Arch Linux package. Thanks Sven for your excellent packaging skills! 🙂
Update: in your plugins.cfg, do not use “$HOME” as your PluginFolder. This seems to cause issues when you run your ogre app. Instead, expand $HOME manually (in my case, to ‘/home/thiago’). This is not much portable, I know, but there must be some workaround for this I haven’t discovered yet.
- Image credit: a screenshot from the “Clean Code” software engineering book by Robert C. Martin (a good one, by the way).