I’ve been investigating cmake at work as a better build system for our cross platform C based projects. I’m thinking about starting up a third one, so now is the prefect time to really go after this as for one project we have a build system per platform and on the other we have two build systems. When you mix in wanting to make universal binaries on OS X its yet another wrinkle. cmake was recently chosen by KDE to be the build system for KDE4 since KDE4 will be fully supporting Windows and OS X, as well as the other unicies via X. I used a small convenience library as the test piece as it was only two files big, but it had the requirement of at least two external libraries.
Some pros for cmake that I’ve found so far (compared to what we’ve been doing):
- support a big number of build environments on the different platforms. On windows it sports 11 different build environments, OS X 3, and Linux 2. For OS X and Linux, you only really need those two or three, but on windows it supports 4 different versions of visual studio as well as Borland, Watcom, and gcc.
- Takes care of the flags needed to build executables and libraries on those supported platforms.
- Does out of source builds on windows.
- Tracks dependences on all platforms without an external application
- Does search and replacing on things like .in files without having to call out to external applications
Some cons I’ve found so far:
- The documentation on the web page is pretty horrid. The book is pretty bad too, especially when compared to other technical books I’ve read recently, but its much better than the website. When combined with the book and experimentation, the FAQ is helpful.
- Doesn’t really have the concept of convenience libraries. This will result in common files being built multiple times. I don’t like this, but its not fatal.
- The CMakeCache is getting in my way more than being a help, but that might be the side effect of my learning process right now.
- I haven’t yet figured out how to make it query the person compiling the app if it can’t find something. This may not be possible. At the very least I want to make it bitch and bomb out if a required dependency isn’t there. I just haven’t found it yet, I’m thinking.
This isn’t an exhaustive review yet, but I wanted to get down what was in my mind before I forgot. I had just found the convenience library thing and that’s what inspired the post. My next step is to move a full existing project over to being built with cmake. This is a library that depends on expat, boost, curl, antlr, and (optionally) swig. Should be a good challenge.
[Update 11:58: I found an answer to my “bomb out if the dependencies are missing” question. Thanks, devchannel!]
[Update 2:51: No this isn’t here just for g0ff. Turns out the latest cmake has modules to Find Java, Doxygen, Boost, Curl, Expat, and Swig already. It looks like just custom items for antlr and cppunit will be needed. Also, it only ever wants to link against dynamic libraries, not static ones. That’s a PITA.]
[Update 5:52: Okay, the convenience library thing is upsetting. The output of what I was working on is a static library and there are same example command line tools that link against it. From my reading of the cmake stuff, I should just include the library source files to the target for the executables being created. The problem with this is for n example programs, I’m compiling librets n times. This doesn’t seem very optimal.]