Difference between revisions of "CMake"

From Eigen
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[Category:Developer]]
 +
 
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 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.
  
Line 4: Line 6:
  
 
CMake distinguishes between the ''source directory'' and the ''build directory'':
 
CMake distinguishes between the ''source directory'' and the ''build directory'':
* The ''source directory'' is your checkout of eigen2. It contains a CMakeLists.txt file.
+
* 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 ''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 command are:
+
The typical startup commands are:
  
 
   $ mkdir builddir  # create build directory
 
   $ mkdir builddir  # create build directory
 
   $ cd builddir      # enter build directory
 
   $ cd builddir      # enter build directory
   $ cmake /path/to/eigen2
+
   $ cmake /path/to/eigen
  
 
Subsequently you can re-run cmake by just doing:
 
Subsequently you can re-run cmake by just doing:
Line 26: Line 28:
 
   $ cmake -DCMAKE_INSTALL_PREFIX=/usr .
 
   $ cmake -DCMAKE_INSTALL_PREFIX=/usr .
  
From there, for example, you have an 'install' target that you can use to install Eigen. For example, on Make-based platforms, just do:
+
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
 
   $ make install

Latest revision as of 00:24, 4 October 2010


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.