The trouble with developing a project which is not only cross-platform, but is old mature & wizened enough to have users dotted across a whole history of incompatible versions of the same tool, is that you end up having to maintain a ton of project files. Linux makefiles, 3+ versions of Visual Studio, Code::Blocks, XCode, Eclipse – it all gets a little unmanageable. I’ve been meaning to look at cross-environment build managers like CMake for a long time, but the time investment required to port & test, let alone learning how to do it, was daunting enough that it never seemed to make it to the top of my TODO. One of the problems was that despite CMake being well respected (projects like KDE and VTK use it), the documentation is a little impenetrable – most of the online stuff being a pretty dry reference that’s difficult to get started with. There is a book, but it’s hard to get hold of and the prices are just crazy even for a technical book – Amazon sellers were asking 70 quid for it used! As such I was never sure if it was going to work out and didn’t really have the spare time to try it.
But, as is so often the case, here’s where the open source community steps in and helps out. CABAListic (aka Holger) has been working really hard not only to get OGRE building with CMake, but doing a damn fine job of it too, with the kind of attention to detail that really makes all the difference. He’s done all the heavy lifting, and by looking at his work I’ve been able to get up to speed fairly quickly, both with the principles and some good practices, and I’m really starting to like CMake a great deal. Right now, it exists in parallel with the other builds in trunk, but relatively soon we’re expecting to make CMake the primary build system – I’m even skipping updating the old project files for the new paging component I’m writing right now and going straight to CMake, and it’s really very nice to use. Sure, you have to edit text files, but they’re easy once you have a pattern defined, and the way CMake checks them before building & refreshes the generated configuration is pretty slick. And I certainly won’t miss poring through page after page of project settings in VS, sometimes for each build configuration, to manually tweak options for multiple projects.
As well as not needing to update so many project files (the exception is XCode which will be separate for now, since I’ve yet to figure out if CMake can do everything I need it to, given the oddities of frameworks and universal binaries on OS X), it’s nice to be able to give people an interface to creating custom OGRE builds (e.g. enabling threading modes, double-precision, static linking etc), and the ability to build them into external directory structures from one source release. Having the equivalent of a ‘configure’ step (as seen on Linux) everywhere is also very nice, for performing sanity checks on dependencies and the like. Also, the fact that the source build collates the final result in a separate location means we can finally unify the directory structures as viewed by 3rd parties between the SDK and source releases, which will smooth things for people moving between the two or publishing add-ons for people using both. We can also provide CMake files to make it easier for people to locate OGRE when they want to build against it.
Doing something as major as replacing the entire build mechanism for a project is pretty significant, but I can already see the benefits. Huge thanks to CABAListic for getting this rolling!









March 6th, 2009 at 11:09 pm
I’ve been using cmake for awhile now and really love it.
I have modules for finding Ogre, CEGUI, etc here if anyone wants to use them for their own projects.
http://bazaar.launchpad.net/~hardwar/hardwar/trunk/files/head%3A/trunk/cmake//modules/
March 7th, 2009 at 11:50 am
Thanks – best to post in the forum thread – I think CABAListic’s already got these in hand but it can’t hurt to look at more.
March 7th, 2009 at 4:43 pm
Another advantage of cross platform build tools, is the ability to use wider range of continuous integration tool to do the whole, automatically build in ten different formats, then test each one individually. Granted, I’m more of a Java/.NET man than C++, but thats what I really like about Ant/NAnt rather than a proprietary, or undocumented build tool like MSBuild
March 7th, 2009 at 5:25 pm
I include Ogre in my game’s VStudio solution to get better debugging and intellisense. Instead of the premade projects that I have to adapt anyway, I would prefer building Ogre was a matter of including the right files. There’s no need for the plugin architecture this way, also.
March 7th, 2009 at 10:30 pm
Just for your information, Notepod++ does syntax highlighting for CMake files. Makes it a bit easier to work with. I expect that KWrite/Kate will do the same on Linux, but I haven’t checked.
March 8th, 2009 at 11:23 am
@John: yeah, we used Ant to automate all our builds in Java. CMake’s nicer though because it combines the ability to automate and to generate useful IDE setups.
@Bruno: you don’t need to physically include the files to do that – I usually just add the Ogre .vcproj to get easier intellisense & debugging capabilities.
@PolyVox: cool, thanks – I generally use GVim on Windows but I keep meaning to give Notepad++ a go, will do that.
March 11th, 2009 at 1:43 am
For automating, I’ve had success with Premake in my cross platform projects. The learning curve is not steep and it generates project files for IDEs other than MSVC. Does CMake support other IDEs (CodeBlocks)? A front end could be developed for OGRE’s build settings if desired, which could look similar to Ogre’s run-time display config editor, but Premake doesn’t come with this out of the box. I realize that the front end for CMake has big appeal to its users, but only those that are working on Windows get this feature, as the last time I checked I saw no front end for CMake on linux/mac.
March 11th, 2009 at 11:14 am
CMake supports MSVC, Linux makefiles, Code::Blocks (MinGW and Linux), Eclipse, XCode. And there is a GUI on the Mac, because I use it
Essentially the choice was governed by the submission of an almost-finished system by CABAListic, but CMake does appear to do more than premake, for C++ anyway. Premake doesn’t do XCode or Eclipse for example, doesn’t have the config GUI (very handy), doesn’t seem to have an equivalent of CPack. So on balance I’m happy he chose CMake.
March 11th, 2009 at 5:23 pm
To follow up on the “continuous integration tool”. CMake includes CTest, and CTest has the ability to send data to CDash http://www.cdash.org. You can setup a project here: http://www.cdash.org/CDashPublic/ to try it out.
January 17th, 2010 at 9:34 pm
I’m using cmake in a couple of projects.
The biggest benefit for premake is that it can create XBox 360 or PlayStation 3 projectfiles, but I supposed Ogre is not targetting professional game developers yet
January 21st, 2010 at 6:51 am
I think CMake can easily call premake to do that job.
necromancer!