CMake: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 28: | Line 28: | ||
Then you can type <code>make</code> and <code>make install</code>, and you're good to go. Don't forget to add <code>/path/to/cmake/build/bin</code> to your <code>$PATH</code>! | Then you can type <code>make</code> and <code>make install</code>, and you're good to go. Don't forget to add <code>/path/to/cmake/build/bin</code> to your <code>$PATH</code>! | ||
=Advantages and Disadvantages= | |||
==Advantages== | |||
==Disadvantages== | |||
===Finding Packages=== | |||
Using the CMake function find_package() can cause many difficulties, because Cmake has an unusual way of dealing with software dependencies. Unlike GNU autotools, you can't always point CMake to a path where you built something and expect it to "just work". (Boost is an excellent example of this.) | |||
CMake contains pre-existing "rules" for finding things that can make life difficult for people who specify <code>--prefix</code> when they install things. CMake contains a list of rules in <code>/path/to/cmake/X.X/Modules/cmake-X.X/</code>. These rules will be in files named Find(Package).cmake (e.g. FindBoost.cmake). | |||
While these can be customized, they are cryptic and can take a long time to try and figure out. Due to these esoteric "find rules", it can be difficult to get CMake to "pick up" on custom installs of third-party packages like Boost. This isn't the case with all third-party packages, just the ones for which "find rules" exist. | |||
= Presentations = | = Presentations = | ||
Revision as of 01:31, 6 April 2011
Cmake is a build system for C++ projects. It is an alternative to autotools.
Installing
Downloading
You can either visit http://www.cmake.org and download the binary, or you can use wget:
$ wget http://www.cmake.org/files/v2.8/cmake-X.Y.Z.tar.gzand untar it using tar:
$ tar xvzf cmake-X.Y.Z.tar.gzConfiguring
Cmake is straightforward to install. It is intended to replace autotools, but it still uses autotools to build it - but a little differently.
You can configure it by running:
$ ./bootstrap --prefix=/path/to/cmake/buildThen you can type make and make install, and you're good to go. Don't forget to add /path/to/cmake/build/bin to your $PATH!
Advantages and Disadvantages
Advantages
Disadvantages
Finding Packages
Using the CMake function find_package() can cause many difficulties, because Cmake has an unusual way of dealing with software dependencies. Unlike GNU autotools, you can't always point CMake to a path where you built something and expect it to "just work". (Boost is an excellent example of this.)
CMake contains pre-existing "rules" for finding things that can make life difficult for people who specify --prefix when they install things. CMake contains a list of rules in /path/to/cmake/X.X/Modules/cmake-X.X/. These rules will be in files named Find(Package).cmake (e.g. FindBoost.cmake).
While these can be customized, they are cryptic and can take a long time to try and figure out. Due to these esoteric "find rules", it can be difficult to get CMake to "pick up" on custom installs of third-party packages like Boost. This isn't the case with all third-party packages, just the ones for which "find rules" exist.
Presentations
Professor James Sutherland's presentation on using CMake, part of the 2010 Scientific Computing Summer Workshop, is here: File:CMake Sutherland.pdf
This presentation contains an example of a "Hello World" program built with CMake.
References
- Explanation of how the
find_package()function works: http://www.itk.org/Wiki/CMake:How_To_Find_Libraries