CMake

From Ert

Jump to: navigation, search

Prerequisites

To be able to build ERT or parts of ERT, CMake 2.8 is needed.

ERT depends on [ http://plplot.sourceforge.net/ PLplot] for plotting. ERT is known to work with PLplot version 5.9.

The python libraries depend on Python 2.7.

The ERT graphical user interface also depends on

and the following Python packages:

In addition Spinx is needed to compile the documentation.

Building with CMake

ert is built with the build system CMake. CMake is a portable frontend system which creates native build files. On Linux the default is for cmake to create normal Linux makefiles, but CMake can in addition create Visual Studio solution files, Eclipse projects files and also build files for Mac OSX. When the cmake generate process is complete you the subsequently invoke the standard build command, i.e. make on Linux, to complete the build.

CMake scans the source files in the project to detect dependencies, and it 'knows' how to create libraries and executables with different compilers and platforms. The typical CMake usage is one or several configuration steps, and then subsequently a generate step to create the final build files. CMake supports out-of-tree builds, i.e. the use of different directories for build and source - this is highly recommended. When using CMake as build system you typically invoke CMake only once to let CMake inspect your configuration and determine the dependencies, afterwards you can invoke the final build system (e.g. make directly).

The CMake configuration file must be called CMakeLists.txt. When invoking CMake you give the path to the directory containing the CMakeList.txt file as a commandline argument; all build files will be placed in the location where you invoke CMake. So in the case of ERT, if you make a directory build/ at the same level as the devel/ directory you can invoke CMake as:

cmd> ccmake ../devel         ;; We give path to directory containing the CMakeLists.txt file.

There are three different frontends to CMake (not necessarily all installed)

You can invoke CMake three different ways:

cmake
This is the simplest commandline line version, options are passed as -DOPTION_VALUE
ccmake
This is a simple ncurses frontend which allows interactive editing of the build options.
CCmake / cmake-gui /... 
This is Qt based gui frontend; the gui is very basic and does not give much added value compared to the ncurses based version.

Use of one of the interactive options is highly recommended.

The ERT CMake setup

The ERT compilation and installation is set up in the CMakeLists.txt file in the following way:

Which part of ERT that is built is decided by the BUILD_* flags. If all the BUILD_* flags are set to off only the C ECLIPSE library libecl and the libraries needed to support libecl are built. At this basic level the ERT code is portable to Windows and MacOSX. Note that only static libraries are supported on Windows, and as a result the python bindings are not available.

The following flags control the other parts that can be built:

BUILD_ERT Build the ERT including the textual user interface.
ERT_BUILD_GUI Build the graphical user interface for ERT.
BUILD_PYTHON Build Python wrappers for the selected libraries, see ERT-Python.
BUILD_ENS_PLOT Build the ens_plot utility used to plot the summary results from many ECLIPSE simulations in one plot.
BUILD_APPLICATIONS Build small, stand-alone utility programs, mainly for use with ECLIPSE files.
BUILD_ECL_SUMMARY Build the ecl_summary program, used to quickly extract summary vectors from ECLIPSE summary files.
BUILD_SHARED_LIBS Build the shared libraries for dynamic linking. If set to OFF only the static version of the libraries are built.
BUILD_TESTS Build the unit tests that can be run using ctest. Many test require data internal to Statoil, and are marked with StatoilData.

Most of the other configuration options should automatically be set to sensible options, but the following options might need to be tweaked:

CMAKE_INSTALL_PREFIX Set the path where ERT is installed.
SITE_CONFIG_FILE Path to the site-config file.
USE_RUNPATH (Only applicable on Linux if BUILD_SHARED_LIBS is set). If ON the executables are built with RPATH set to help locate the dynamic libraries. This eliminates the need for setting LD_LIBRARY_PATH, but makes it impossible to move the shared libraries after installation.

To build all of ERT you must set the BUILD_ERT variable to ON. Then you must type c to configure (several times) and finally g to generate and exit. Then you can type make for a normal build.

Observe that the ERT CMake setup is configured to store the output variables in the directory devel/build/. Also observe that the output found in devel/build/.. makes use of -rpath, i.e. these files should not just be copied to a installation directory. Make use of the make install target which will relink all dynamic executables as part of the installation process.

You can make quite substantial changes to your source, including to add and delete files from the build, without necessitating a new CMake run.

Personal tools
Namespaces
Variants
Actions
Navigation
Download code
Support
Toolbox