Building ROOT with CMake

ROOT can now be build using the CMake build system (version 2.8). The installed libraries and executables should be compatible to the standard build of ROOT.  CMake generates native makefiles and workspaces (i.e. Xcode, Eclipse, Visual Studio) that can be used in the compiler environment of your choice. The main difference with respect the Module.mk build is that the build is done out of the source tree, which allows several build configurations in parallel (debug, non-debug, optional components, etc.).  The main advantage with respect the standard build system is that for the Windows platform it does not require the installaton of CygWin.

So far the CMake build of ROOT has been validated for Scientific Linux (gcc, icc), MacOS X (gcc) and Windows (vc++). Other platforms will be added later. In addition, a  number of prerequisite packages must be installed. Check the prerequisites page for the list of packages needed for your platform.

Getting Prepared

  • First you need to install CMake in your system. Binary distributions can be obtained from the CMake download area. Ensure that the PATH variable is modified accordingly to locate the cmake executable.
  • Then you need to download and unpack the ROOT's sources from the download area or using directly the Git repository. Follow the instructions for getting the ROOT sources.

Quick Start

The following are the basic instructions for UNIX systems

  1. Get the sources of ROOT (see above)
  2. Type the build commands:
    mkdir <workdir>
    cd <workdir>
    cmake <srcdir> [-DCMAKE_INSTALL_PREFIX=<installdir>] [see possible options later]
    make                      [or, make -j n for n core machines]
    make install
  3. Add bin/ to PATH and lib/ to LD_LIBRARY_PATH. For the sh shell family do:
    . <installdir>/bin/thisroot.sh
  4. Try running ROOT:
    root

Build Options

The user can set any CMake variable or option that controls the build process from the cmake command line. The command using the option -D <var>:<type>=<value> creates an entry in the CMake cache. Here is a quick summary of the most important ones:

-DCMAKE_BUILD_TYPE=Debug     # Other build types: Release, RelWithDebInfo, MinSizeRe
-DCMAKE_INSTALL_PREFIX=<installdir> # installation prefix
-DCMAKE_C_COMPILER=gcc       # What C compiler to use
-DCMAKE_CXX_COMPILER=c++     # What C++ compiler to use
-DCMAKE_F_COMPILER=gfortran  # What fortran compiler to use
-DCMAKE_LINKER=ls            # What linker program to use<br>
-Dxxxx=ON -Dyyyy=OFF         # Optional ROOT components (e.g. tmva, mathcode, gdml, etc.)

The full list of available options is listed later in this document.  

CMake Generators

CMake can generate, in addition to standard makefiles, specific proejcts for various integrated development environments (IDEs) such as Xcode, Eclipse, Visual Studio, etc.. The available generators depend on the platform for which cmake have been build. To see the list of available generators do cmake --help.

Xcode

Generate the Xcode project with cmake -G "Xcode" <ROOT source>. Open the generated file with the Xcode application.

Visual Studio  10

Generate the Microsoft Visual Studio soultion with cmake -G "Visual Studio 10" <ROOT source>

Open the generated solution with "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" ROOT.sln

External Libraries

ROOT requires a number of external libraries that the CMake system needs to locate. The list of externals depends on the build options that have been enabled.  CMake will look for these third party products at a number of standard places in your system but the user can influence the search by setting some environment variables before invoking the CMake command or by setting package specific CMake variables to their exact location. 

The actual cached values used by CMake for the exact location of libraries and include files of the used external libraries can be inspected and modified using the ccmake utility.  

AfterImage

AFTERIMAGE_CONFIG_EXECUTABLE Full path to afterimage-config program

Bonjour

BONJOUR_INCLUDE_DIR Directory where to find dns_sd.h
AVAHI_INCLUDE_DIR Directory where avahi-client/client.h (Linux)
AVAHI_client_LIBRARY Full path to libavahi-client.so library

CASTOR (CERN Advanced STORage manager)

${CASTOR_DIR} Environment variable to the Castor installation.
or
CASTOR_INCLUDE_DIR Path to rfio_api.h file
CASTOR_shift_LIBRARY Full path to shift/span> library

CFITSIO - A FITS File Subroutine Library

${CFITSIO} Installation of CFITSIO
or  
CFITSIO_INCLUDE_DIR Directory where to find fitsio.h
CFITSIO_LIBRARIES Full path to cfitsio library

FFTW    

${FFTW_DIR} Installation of FFTW
or  
FFTW_INCLUDE_DIR Directory where to find fftw3.h
FFTW_LIBRARY Full path to fftw3 library

GCCXML   

GCCXML_EXECUTABLE Full path to gccxml program

GraphViz    

${GRAPHVIZ_DIR} Installation of GraphViz
or  
GRAPHVIZ_INCLUDE_DIR Directory where to find graphviz/graph.h
GRAPHVIZ_CDT_LIBRARY Full path to cdt library
GRAPHVIZ_GVC_LIBRARY Full path to gvc library
GRAPHVIZ_GRAPH_LIBRARY Full path to graph library
GRAPHVIZ_PATHPLAN_LIBRARY Full path to pathplan library

 

GSL (GNU Scientific Library)

${GSL_DIR} Environment variable to the GSL installation.
or
GSL_CONFIG_EXECUTABLE Full path to gsl-config program

Kerberos 5   

${KRB5_DIR} Installation of Kerberos5
or  
KRB5_INCLUDE_DIR Directory where to find krb5.h 
KRB5_MIT_LIBRARY Full path to k5crypto library
KRB5_LIBRARY Full path to krb5 library
KRB5_INIT Full path to kinit program

LZMA         

${LZMA_DIR} Installation of LZMA
or  
LZMA_INCLUDE_DIR Directory where to find lzma.h
LZMA_LIBRARY Full path to lzma library

MySQL        

${MYSQL_DIR} Installation of MySQL
or  
MYSQL_CONFIG_EXECUTABLE Full path to mysql_config program

ODBC         

${ODBC_DIR} Installation of ODBC
or  
ODBC_INCLUDE_DIR Directory where to find sqlext.h
ODBC_LIBRARY Full path to libodbc library

Oracle

${ORACLE_DIR} Environment variable to the Oracle installation.
or
ORACLE_INCLUDE_DIR Location where to find oci.h   
ORACLE_LIBRARY_OCCI Full path to libocci library 
SQLPLUS_EXECUTABLE Full path to the sqlplus program

OpenGL

OPENGL_INCLUDE_DIR Location where to find GL/gl.h   
OPENGL_gl_LIBRARY Full path to GL library 

PCRE        

PCRE_CONFIG_EXECUTABLE Full path to pcre_config program

PostgreSQL         

POSTGRESQL_INCLUDE_DIR Directory where to find libpq-fe.h
POSTGRESQL_LIBRARIES Full path to pq library

Pythia 6        

PYTHIA6_LIBRARY Full path to pythia6 library

Pythia 8         

${PYTHIA8_DIR} Environment variable pointing to installation of Pythia8
or  
PYTHIA8_INCLUDE_DIR Directory where to find Pythia.h
PYTHIA8_LIBRARY Full path to Pythia8 library

 

Python      

PYTHON_EXECUTABLE Python interpreter executable
PYTHON_INCLUDE_DIR Directory where to find Python.h
PYTHON_LIBRARY Full path to Python library

 

ROOT build options

Each build option is a boolean variable that can be turned ON or OFF. The current value is recorded in the CMake cache (CMakeCache.txt file on the build directory) and therefore it is not needed to be specified on the cmake command line each time. Please note that some of the options might be turned OFF automatically for some platforms or if the required external library or compoment can not be satisfied. The user can view and edit the full list of options using the ccmake utility or cmake-gui for Windows. Note that some of the options are not yet implemented.

# option name    | default value | description
afs                OFF "AFS support, requires AFS libs and objects"
alien             ON  "AliEn support, requires libgapiUI from ALICE"
asimage            ON  "Image processing support, requires libAfterImage"
astiff             ON  "Include tiff support in image processing"
bonjour            ON  "Bonjour support, requires libdns_sd and/or Avahi"
builtin_afterimage OFF "Built included libAfterImage, or use system libAfterImage"
builtin_ftgl       ON  "Built included libFTGL, or use system libftgl")
builtin_freetype   OFF "Built included libfreetype, or use system libfreetype"
builtin_glew       ON  "Built included libGLEW, or use system libGLEW"
builtin_pcre       OFF "Built included libpcre, or use system libpcre"
builtin_zlib       OFF "Built included libz, or use system libz"
builtin_lzma       OFF "Built included liblzma, or use system liblzma"
builtin_gsl        OFF "Build the GSL library internally (downloading tarfile from the Web)"
builtin_cfitsio    OFF "Build the FITSIO library internally (downloading tarfile from the Web)"
builtin_xrootd   OFF "Built the XROOTD internally (downloading tarfile from the Web)"
c++11              OFF "Build using C++11 compatible mode, requires gcc > 4.7.x or clang"
castor             ON  "CASTOR support, requires libshift from CASTOR &gt;= 1.5.2"
chirp              ON  "Chirp support (Condor remote I/O), requires libchirp_client"
cintex             ON  "Build the libCintex Reflex interface library"
clarens            ON  "Clarens RPC support, optionally used by PROOF"
cocoa              OFF "Use native Cocoa/Quartz graphics backend (MacOS X only)"
cling              ON  "Enable new CLING C++ interpreter" 
dcache             ON  "dCache support, requires libdcap from DESY"
exceptions         ON  "Turn on compiler exception handling capability"
explicitlink           "Explicitly link with all dependent libraries"
fftw3              ON  "Fast Fourier Transform support, requires libfftw3"
fitsio             ON  "Read images and data from FITS files, requires cfitsio"
gviz               ON  "Graphs visualization support, requires graphviz"
gdml               OFF "GDML writer and reader"
genvector          ON  "Build the new libGenVector library"
gfal               ON  "GFAL support, requires libgfal"
glite              ON  "gLite support, requires libglite-api-wrapper v.3 from GSI (<a href="https://subversion.gsi.de/trac/dgrid/wiki" title="https://subversion.gsi.de/trac/dgrid/wiki">https://subversion.gsi.de/trac/dgrid/wiki</a>)"
globus             OFF "Globus authentication support, requires Globus toolkit"
gsl_shared         OFF "Enable linking against shared libraries for GSL (default no)"
hdfs               ON  "HDFS support; requires libhdfs from HDFS &gt;= 0.19.1"
krb5               ON  "Kerberos5 support, requires Kerberos libs"
ldap               ON  "LDAP support, requires (Open)LDAP libs"
mathmore           ON  "Build the new libMathMore extended math library, requires GSL (vers. >= 1.8)"
memstat                "A memory statistics utility, helps to detect memory leaks"
minuit2            OFF "Build the new libMinuit2 minimizer library")
monalisa           ON  "Monalisa monitoring support, requires libapmoncpp"
mysql              ON  "MySQL support, requires libmysqlclient"
odbc               ON  "ODBC support, requires libiodbc or libodbc"
opengl             ON  "OpenGL support, requires libGL and libGLU"
oracle             ON  "Oracle support, requires libocci"
peac               ON  "PEAC, PROOF Enabled Analysis Center, requires Clarens"
pgsql              ON  "PostgreSQL support, requires libpq"
pythia6            ON  "Pythia6 EG support, requires libPythia6"
pythia8            ON  "Pythia8 EG support, requires libPythia8"
python             ON  "Python ROOT bindings, requires python >= 2.2"
qt                 OFF "Qt graphics backend, requires libqt >= 4.x"
qtgsi              OFF "GSI's Qt integration, requires libqt >= 3"
reflex             ON  "Build the libReflex dictionary library"
roofit             OFF "Build the libRooFit advanced fitting package"
ruby               OFF "Ruby ROOT bindings, requires ruby >= 1.8"
rfio               ON  "RFIO support, requires libshift from CASTOR <= 1.5.2"
rpath              OFF "Set run-time library load path on executables and shared libraries (at installation area)"
sapdb              ON  "MaxDB/SapDB support, requires libsqlod and libsqlrte"
shadowpw           ON  "Shadow password support"
shared             ON  "Use shared 3rd party libraries if possible"
soversion          OFF "Set version number in sonames (recommended)"
srp                ON  "SRP support, requires SRP source tree"
winrtdebug         OFF "Link against the Windows debug runtime library"
xft                ON  "Xft support (X11 antialiased fonts)"
xml                ON  "XML parser interface"
x11                    "X11 support"
xrootd             ON  "Build xrootd file server and its client (if supported)"