CMake is a cross-platform, open-source meta build system to build, test and package software. It creates Makefile or other build files (KDevelop, Eclipse). The intention is to test it if people like it and if we could replace the current build system with CMake.
Lets start to do a checkout and compile something. Run some commands and then come back and talk about the features.
$ git clone git://gitorious.org/samba-wip/samba-wip.git $ cd samba-wip $ git checkout -b cmake origin/cmake $ cd lib/talloc
CMake is designed to build out of the source. This has several advantages. You don't have to create thousand of entries in .gitignore. You can create a build directory for *every local git branch* you create. CMake has serverl "configure" tools cmake which is the commandline tool. ccmake which is a ncurses based gui and cmake-gui which is a Qt gui.
$ mkdir build $ cd build $ cmake ..
This is a talloc stand alone build. Normally you have to copy libreplace in the talloc dir but there is a check to look for ../replace, if you're in the Samba tree. It does all the required configure checks here to build on Linux as this is just a test.
I think you know what it does. What's nice it shows only what it's building and the warnings and errors. If you want to see how make/cmake invokes the compiler, try the following:
$ make clean $ make VERBOSE=1
To see what targets are availalbe, you can use
$ make help
If you go to a source directory you have a target for each .c file.
$ cd replace $ make help $ cd ..
You can execute every binary in the build directory and it will work. The reason is that it uses rpath to build executables that they are able to find the libraries. Everthing gets relinked during installation. You can disable it completely too.
$ ldd talloc_testsuite
Advantages of CMake as a list
- Out of source build
- Automatic dependency generation (parallel builds)
- Build system in *one* language
- Good documentation (man cmake)
- Works on a lot of different machines and operating systems -> http://www.cdash.org/CDash/index.php?project=CMake
- Complex custom commands: qt moc, yacc, pidl!
- Reuns itself if one of the input files has changed