Overview

ODB API uses CMake for compilation and installation. This is a first step towards an homogenisation of the installation procedures for all ECMWF packages.

Like autotools, CMake will run some tests on the user's system to find out if required third-party software libraries are available and note their locations (paths). Based on this information it will produce the Makefiles needed to compile and install ODB API.

CMake is a cross-platform free software program for managing the build process of software using a compiler-independent method.

Generating the Makefiles with CMake

One nice and highly recommended feature of CMake is the ability to do out of source builds. In this way you can make all your ".o" files, various temporary depend files, and even the binary executables without cluttering up your source tree. To use out of source builds, first create a build directory, then change into your build directory and run cmake pointing it to the source directory and using your own options.

The command gives feedback on what requirements are fulfilled and what software is still required. The following table gives an overview of the different options.  The default (without any options) will compile a shared library only and install it in /usr/local/.

 

CMAKE_INSTALL_PREFIXwhere you want to install your ODB API/usr/local
CMAKE_BUILD_TYPE

to select the type of compilation:

  • Debug
  • RelWithDebInfo
  • Release
  • Production
RelWithDebInfo
BUILD_SHARED_LIBSSelect the type of library built:
  • ON (Build shared libraries only)
  • OFF (Build static libraries only)
  • BOTH (Build both shared and static libraries)
ON
CMAKE_CXX_COMPILERC++ compiler 
CMAKE_CXX_FLAGSFlags for the C++ compiler 
CMAKE_C_COMPILERC compiler 
CMAKE_C_FLAGSFlags for the C compiler 
CMAKE_Fortran_COMPILERFortran compiler 
CMAKE_Fortran_FLAGSFlags for the Fortran compiler 
ENABLE_NETCDFBuild odb2netcdf toolAUTO
ENABLE_PYTHONBuild Python interface for ODB APIAUTO
ENABLE_FORTRANBuild Fortran interface for ODB APIAUTO
ENABLE_MIGRATORBuild odb_migrator tool for importing legacy ODB databases 
ODB_SOURCEDirectory with source of the legacy ODB software 
ODB_PATHPath to legacy ODB installation 
cmake options
doc
default


Note: The compilers can also be overridden by setting the environment variables CC and FC.

Note: To see the full output from the compilation, you can use:

Build in verbose mode
$ make VERBOSE=1  

Quick installation guide

Here are example commands that you could use to install ODB API. Dollar sign ($) is a typical shell prompt.

Basic installation procedure
$ tar -xzf  ODB_API-x.y.z-Source.tar.gz
$ mkdir build ; cd build 

$ cmake -DCMAKE_INSTALL_PREFIX=/path/to/where/you/install/odb_api ../ODB_API-x.y.z-Source 
...

$ make
$ ctest
$ make install


It is recommended that you always build in a clean directory and also install into a clean directory.

Note that for the testing step (running the ctest command) you need to be connected to the internet (and set the relevant "http_proxy" environment variable if you must use a proxy) so data files can be downloaded for the tests.
Also note that if you have several CPUs, you can invoke the "make" and "ctest" commands above in parallel (e.g. "make -j4").  This will speed up the whole build/test process significantly.