CMake

From Eigen
Jump to: navigation, search


CMake is a cross-platform tool to generate files for your platform's native build system. For example, on Unix it generates Makefiles (so you subsequently use 'make'), on Windows/MSVC it generates project files, etc.

CMake is most probably available for your platform, see their website. On Unix systems, it is probably available from your package manager.

CMake distinguishes between the source directory and the build directory:

  • The source directory is your checkout of the eigen repository. It contains a CMakeLists.txt file.
  • The build directory is a directory that you create yourself, and from which you run cmake. The first time you run cmake, pass it the path to the source directory. All CMake-generated files will go there.

The typical startup commands are:

 $ mkdir builddir   # create build directory
 $ cd builddir      # enter build directory
 $ cmake /path/to/eigen

Subsequently you can re-run cmake by just doing:

 $ cmake .

as it already knows the path to the source directory.

CMake manages a large number of cached variables. You can see them using various tools, for examples this curses-based interface:

 $ ccmake .    # and then press the 't' key to see them all

If you want to change the value of a variable and rerun cmake against it, pass -DVARIABLE=newvalue, for example:

 $ cmake -DCMAKE_INSTALL_PREFIX=/usr .

From there, you can run your native buildsystem (for example 'make') on various targets. For example, on Make-based platforms, to install Eigen, just do:

 $ make install

You could also build the API documentation (requires Doxygen and LaTeX):

 $ make doc

See the Tests page about building/running the unit tests.