-
Notifications
You must be signed in to change notification settings - Fork 30
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.
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.
To configure and build as simply as possible do
cmake ../imp
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:
cmake ../imp -DCMAKE_BUILD_TYPE=Debug -G Ninja -DIMP_DISABLED_MODULES=cgal:membrane -DIMP_PER_CPP_COMPILATION=core
ninja -j 8
- run
ccmake ../imp
You can then look through the various options available. - If you want a debug build, set
CMAKE_BUILD_TYPE
toDebug
- tell cmake to configure (hit
c
) and generate (hitg
) make -j 8
You can run ccmake
after running cmake
as above if you want, too. Running it never hurts.
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 ofNONE
,USAGE
,INTERNAL
to control what check levels will be supported. -
IMP_MAX_LOG
: One ofSILENT
,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 ofDebug
orRelease
.
An equivalent of the scons fast
build is to set
CMAKE_BUILD_TYPE=Release
IMP_MAX_CHECKS=NONE
IMP_MAX_LOG=SILENT
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 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).