Skip to content
benmwebb edited this page Aug 12, 2014 · 41 revisions

Why use CMake

IMP is now built using CMake. The key advantage of cmake over scons is that cmake separates the configure and build phases making edit, build, test loops much faster when you make small changes. When used with ninja compilation starts almost instantly.

Building IMP with CMake

There are two different ways to configure with cmake, one is to run cmake in a fresh directory passing some options on the command line and the other is to run ccmake and use its editor to change options. For both, assume you are in a directory called debug and the IMP source is in a directory at ../imp. We are using the default of makefiles for the actual building.

Configuring with cmake

To configure and build as simply as possible do

  1. cmake ../imp
  2. make -j 8

To make a debug build of IMP with the cgal and membrane modules disabled and core compiled in per-cpp mode, and use Ninja as your build command do:

  1. cmake ../imp -DCMAKE_BUILD_TYPE=Debug -G Ninja -DIMP_DISABLED_MODULES=cgal:membrane -DIMP_PER_CPP_COMPILATION=core
  2. ninja -j 8

Configuring using ccmake

  1. run ccmake ../imp You can then look through the various options available.
  2. If you want a debug build, set CMAKE_BUILD_TYPE to Debug
  3. tell cmake to configure (hit c) and generate (hit g)
  4. make -j 8

You can run ccmake after running cmake as above if you want, too. Running it never hurts.

Further configuration options

You can use ninja instead if it is available by passing -G Ninja to the (c)cmake call. That is highly recommended when it is available.

Various aspects of IMP build behavior can be controlled via variables. These can be set interactively using ccmake (eg ccmake ../imp) or by passing them with -D in a call to cmake. Key ones include:

  • IMP_DISABLED_MODULES: A colon-separated list of disabled modules.
  • IMP_MAX_CHECKS: One of NONE, USAGE, INTERNAL to control what check levels will be supported.
  • IMP_MAX_LOG: One of SILENT, PROGRESS, TERSE, VERBOSE to control what log levels are supported.
  • IMP_PER_CPP_COMPILATION: A colon-separated list of modules to build one .cpp at a time.
  • CMAKE_BUILD_TYPE: one of Debug or Release.

An equivalent of the scons fast build is to set

  • CMAKE_BUILD_TYPE=Release
  • IMP_MAX_CHECKS=NONE
  • IMP_MAX_LOG=SILENT

There also are a variety of standard cmake options which control the build. In particular, if you have dependencies installed in non-standard locations, you may need to set the CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH variables so that cmake can find them.

Testing IMP

Test are run using ctest. A good start is to run ctest --output-on-failure.

Note that things required by the tests are not built automatically; you have to build them first.

Tests are labeled with the module name and the type and cost of the test, so to run just the expensive tests in the atom module, use ctest -L "^IMP\.atom\-test\-.*EXPENSIVE".

Benchmarks are simply tests labeled as benchmark; examples are tests labeled as example.

CMake usage in IMP

CMake is configured in IMP using a CMakeLists.txt file in each application and module bin, src, test and example directory. These CMakeLists.txt are auto generated via tools/build/setup_cmake.py which is run automatically every time cmake is run.

Modules that need to do custom configuration work can put CMake code in a Setup.cmake file in their module directory (see the base module for an example).

Clone this wiki locally