2.3.  Geant4 Build Options

Both Section 2.1 and Section 2.2 give the minimal proceedure to build and install Geant4. Many additional options can be passed to CMake to adjust the way Geant4 is built and installed and to enable optional components.

On the command line, these options may be set by passing their name and value to the cmake command via -D flags, for example

    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/geant4 -DGEANT4_USE_GDML=ON /path/to/geant4.9.5
  

would set up the build of Geant4 for installation under /opt/geant4 and compilation of support for GDML.

In the CMake GUI, the options are listed as textbox entries, and values may be set directly by clicking on the entry for the option and entering the required information (for example, if a path is required, the GUI will pop up a file browser).

On Unix, CMake also provides a curses based interface, ccmake, which can be used to browse and set options in the terminal. Please see the CMake documenation for more information.

If you have already created a build directory and used CMake to configure the build, you can always rerun CMake in that directory with new options to regenerate the buildscripts (Makefiles or IDE solutions). In the CMake GUI, you should set the Where is the source code: path to that of your source directory, and the Where to build the binaries: path to that of the build directory you wish to reconfigure. You will then need to rebuild and reinstall to pick up the changes. You can also deactivate a previously selected option to remove a component from the build. For example, we could do

    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/geant4 -DGEANT4_USE_GDML=OFF /path/to/geant4.9.5
  

to explicitly remove support for GDML from a build (In the CMake GUI, we would simply uncheck the tick box for GEANT4_USE_GDML). Note however that if you reconfigure to unset an option and rebuild and reinstall, your install may contain files installed by the previously set option (for example headers).

Options are divided into Standard options, which any user or developer can set directly, and Advanced options, which in general are only needed by advanced users, developers or to give very fine control over the build and and install. Some options enable components of Geant4 which require external software (as listed in Section 1.2). If these options are enabled, the required software will be searched for, and hence there are also options which control where CMake should look for these packages. If a required software package is not found, then CMake will exit with an error message detailing what was not found.

2.3.1.  Standard Options

We list standard options here in logical order. If you use CMake's curses or GUI interfaces, they will be listed alphabetically.

  • CMAKE_INSTALL_PREFIX

    • Sets the installation prefix for Geant4. Equivalent to --prefix in Autotools. Its default is platform dependent:

      Unix: /usr/local

      Windows: C:\Program Files\Geant4

      It should be supplied as an absolute path, otherwise CMake will interpret its value relative to your build directory.

      See also the CMAKE_INSTALL_XXXDIR Advanced Options for fine control of installation locations.

  • CMAKE_BUILD_TYPE : (DEFAULT : Release)

    • Controls the type of build, at present only the additional flags passed to the compiler. It defaults to Release which gives an optimized build with no debugging symbols. The most useful values are:

      Release : Optimized build, no debugging symbols

      Debug : Debugging symbols, no optimization

      RelWithDebInfo : Optimized build with debugging symbols

      Note that if you use a build system which supports multiconfiguration builds (e.g. Xcode, Visual Studio), this variable has no effect as all build types are available inside the CMake generated project.

  • GEANT4_INSTALL_DATA : (DEFAULT : OFF)

    • If set to ON, download and install all Geant4 data libraries (i.e. G4NDL etc). Each library will be unpacked and installed in a directory named share/Geant4-9.5.0/data under CMAKE_INSTALL_PREFIX.

      REQUIRES : CMake 2.8 or higher and a working network connection. It is highly recommended to switch this option on if you have the requisite CMake version and network connection to give the best integration with application development.

  • GEANT4_USE_GDML : (DEFAULT : OFF | ON if XERCESC_ROOT_DIR is set)

    • If set to ON, build the G4persistency library with support for GDML.

      REQUIRES : Xerces-C++ libraries and headers, see the XERCESC_ROOT_DIR option.

  • XERCESC_ROOT_DIR

    • If your Xerces-C++ installation is in a non-standard location, set this variable to the root directory of the installation (i.e. the directory containing the include and lib subdirectories for Xerces-C++). If this is not sufficient to locate Xerces-C++, see the Advanced XERCESC_INCLUDE_DIR and XERCESC_LIBRARY options.

  • GEANT4_USE_QT (DEFAULT : OFF)

    • If set to ON, build Qt4 User Interface and Visualization drivers.

      REQUIRES : Qt4 and OpenGL libraries and headers. See the QT_QMAKE_EXECUTABLE option.

  • QT_QMAKE_EXECUTABLE

    • If your Qt4 installation is in a non-standard location, set this variable to point to the qmake executable of the Qt4 installation you wish to use. If you have a system install on Linux or the binary SDK install from Nokia on other platforms, Qt4 will in general be found automatically (CMake should also honor the QTDIR environment variable).

  • GEANT4_USE_XM (DEFAULT : OFF, Unix Only)

    • If set to ON, build Motif User Interface and and Visualization drivers.

      REQUIRES : Motif and OpenGL libraries and headers. In most cases, these should be found automatically, but if not, see the Advanced MOTIF_INCLUDE_DIR and MOTIF_LIBRARIES options.

  • GEANT4_USE_OPENGL_X11 (DEFAULT : OFF, Unix Only)

    • If set to ON, build the X11 OpenGL visualization driver.

      REQUIRES : X11 and OpenGL libraries and headers.

  • GEANT4_USE_OPENGL_WIN32 (DEFAULT : OFF, Windows Only)

    • If set to ON, build the X11 OpenGL visualization driver.

      REQUIRES : OpenGL libraries and headers.

  • GEANT4_USE_INVENTOR (DEFAULT : OFF)

    • If set to ON, build the OpenInventor visualization driver.

      REQUIRES : OpenInventor implementation (Coin3d recommended), Xt (Unix) or Win (Windows) binding, and OpenGL libraries and headers. CMake will use coin-config and soxt-config if present to locate the Coin3d implementation, and will honor the COINDIR environment variable. In case of issues with locating the Inventor implementation, see the Advanced INVENTOR_INCLUDE_DIR, INVENTOR_LIBRARY_RELEASE, INVENTOR_SOXT_LIBRARY and INVENTOR_SOWIN_LIBRARY options.

  • GEANT4_USE_RAYTRACER_X11

    • If set to ON, build RayTracer visualization with X11 support.

      REQUIRES : X11 Headers and Libraries.

  • GEANT4_USE_SYSTEM_CLHEP (DEFAULT : OFF | ON if CLHEP_ROOT_DIR set)

    • If set to ON, build Geant4 with an external install of CLHEP. You should not set this unless your usage of Geant4 mandates a specific external CLHEP installation (e.g. if your experiment's software uses CLHEP in other tools and requires consistent use of the same CLHEP across the software). If the CLHEP_ROOT_DIR option is not set, CLHEP will be searched for under standard system paths.

      REQUIRES : CLHEP libraries and headers.

  • CLHEP_ROOT_DIR

    • If you wish GEANT4 to use a specific installation of CLHEP, set this variable to point to the root install directory of the CLHEP installation you wish to use. This directory should contain the include and lib subdirectories containing the CLHEP headers and libraries respectively. If this is not sufficient to locate CLHEP, see the Advanced CLHEP_INCLUDE_DIR and CLHEP_LIBRARY options.

2.3.2.  Advanced Options

Most builds should never need to touch the Advanced options, but should you need more control or CMake has problems locating needed software packages, they can be very helpful. We only list the options most relevent for Geant4.

Advanced options are not displayed by default in CMake's curses and GUI interfaces, but can be displayed by pressing t in ccmake, or clicking the 'advanced' check box in the CMake GUI. Note that displaying advanced options will also display a large number of options used by CMake and to record the locations of Third Party packages. On the command line, advanced options can be set like any other option.

  • GEANT4_USE_NETWORKDAWN : (DEFAULT : OFF, Unix Only)

    • If set to ON, build network server/client support for DAWN visualization driver. You do not need this to view DAWN files.

  • GEANT4_USE_NETWORKVRML : (DEFAULT : OFF, Unix Only)

    • If set to ON, build network server/client support for VRML visualization driver. You do not need this to view VRML files.

  • GEANT4_INSTALL_EXAMPLES : (DEFAULT : OFF)

    • If set to ON, install Geant4 example application source code under CMAKE_INSTALL_DATAROOTDIR.

  • BUILD_SHARED_LIBS : (DEFAULT : ON)

    • If set to ON build Geant4 shared libraries.

  • BUILD_STATIC_LIBS : (DEFAULT : OFF)

    • If set to ON, build Geant4 static libraries.

  • CMAKE_INSTALL_BINDIR : (DEFAULT : bin)

    • Installation directory for Geant4 executables. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX or as an absolute path.

  • CMAKE_INSTALL_INCLUDEDIR : (DEFAULT : include)

    • Installation directory for Geant4 C/C++ headers. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX or as an absolute path.

  • CMAKE_INSTALL_LIBDIR : (DEFAULT : lib(+?SUFFIX))

    • Installation directory for object code libraries It can be supplied as a path relative to CMAKE_INSTALL_PREFIX, or an absolute path. By default, SUFFIX will be set to 64 on 64bit Linux platforms apart from Debian systems.

  • CMAKE_INSTALL_DATAROOTDIR : (DEFAULT : share)

    • Installation directory for read-only architecture-independent data files. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX, or an absolute path.

  • XERCESC_INCLUDE_DIR

    • If CMake cannot locate your Xerces-C++ installation, set this to the directory containing the Xerces-C++ headers (e.g. if you have /foobar/xercesc/util/XercesVersion.hpp, then set this to /foobar).

  • XERCESC_LIBRARY

    • If CMake cannot locate your Xerces-C++ installation, set this to the full path to the Xerces-C++ library, e.g. /usr/lib/libxerces-c.so

  • MOTIF_INCLUDE_DIR

    • If CMake cannot locate your Motif installation, set this to the directory containing the Motif headers (e.g. if you have /foobar/Xm/Xm.h, then set this to /foobar).

  • MOTIF_LIBRARIES

    • If CMake cannot locate your Motif installation, set this to the full path to the Motif library, e.g. /usr/lib/libXm.so

  • INVENTOR_INCLUDE_DIR

    • If CMake cannot locate your OpenInventor installation, set this to the directory containing the Inventor headers (e.g. if you have /foobar/Inventor/So.h, then set this to /foobar).

  • INVENTOR_LIBRARY_RELEASE

    • If CMake cannot locate your Inventor installation, set this to the full path to the Inventor Release library, e.g. /usr/lib/libCoin.so

  • INVENTOR_SOWIN_LIBRARY (Windows only)

    • If CMake cannot locate your Inventor installation, set this to the full path to the Inventor SoWin binding library, e.g. c:\Program Files\Coin\sowin.dll.

  • INVENTOR_SOXT_LIBRARY (Unix only)

    • If CMake cannot locate your Inventor installation, set this to the full path to the Inventor SoXt binding library, e.g. /usr/lib/libSoXt.so.

  • CLHEP_INCLUDE_DIR (If GEANT4_USE_SYSTEM_CLHEP selected)

    • If CMake cannot locate your external CLHEP installation, set this to the directory containing the CLHEP headers (e.g. if you have /foobar/CLHEP/Vector/defs.h, then set this to /foobar).

  • CLHEP_LIBRARY (If GEANT4_USE_SYSTEM_CLHEP selected)

    • If CMake cannot locate your CLHEP installation, set this to the full path to the CLHEP library, e.g. /usr/lib/libCLHEP.so

  • GEANT4_BUILD_STORE_TRAJECTORY : (DEFAULT : ON)

    • If set to ON, store trajectories in event processing. It can be switched to OFF to give a degree of performance improvement, but you will not be able to visualize events.

  • GEANT4_BUILD_VERBOSE_CODE : (DEFAULT : ON)

    • If set to ON, build Geant4 libraries with extra verbosity. It can be switched to OFF to give a degree of performance improvement, but you will not have as mush information output should you run into problems or need to debug.

  • GEANT4_BUILD_GRANULAR_LIBRARIES : (DEFAULT : OFF)

    • If set to ON, build Geant4 libraries in granular mode. WARNING: this option is for Geant4 developers only and does not provide a fully usable Geant4 install. No support is, or will be, provided for user applications built with granular libraries.

  • GEANT4_BUILD_EXAMPLES : (DEFAULT : OFF)

    • If set to ON, build all Geant4 example applications using current Geant4 build. WARNING: this option is for Geant4 system testing only and is not intended for use by users studying and working on the examples. No support is, or will be, provided for user builds of the examples using this option.

  • GEANT4_ENABLE_TESTING : (DEFAULT : OFF)

    • If set to ON, build and run Geant4 testing suites. WARNING: this option is for Geant4 system testing only and is not intended for use by users. No support is, or will be, provided for user builds with this option.