Geant4 developers can make use of several powerful features of CMake to help with their work. The key concept and working practice is the separation of the source directory, which is where the sources you edit reside, and the build directory, where the buildscripts and compiled products reside. The reason for enforcing this separation is twofold:
CMake is a buildsystem generator that can
create scripts for many buildsystems including Make,
Xcode, Visual Studio and Eclipse, among others.
To find out which systems your install of CMake can generate
scripts for, consult the "
GENERATORS" section of
the CMake man page, or click on the "
button in the CMake GUI.
The resulting scripts can be used within the buildsystem of choice to
perform the actual build, install and packaging.
Whilst we only support Make and Visual Studio for Unix and Windows user builds respectively, Geant4 developers are welcome, and encouraged, to use their buildsystem of choice. Scripts for developing Geant4 using these systems can be generated by choosing the CMake generator when running CMake for the first time.
On the command line, one can select the tool using the
-G argument of CMake. For example, to generate an
Xcode project for Geant4 using the example from
$ mkdir -p /path/to/geant4.9.6-build-xcode $ cd /path/to/geant4.9.6-build-xcode $ cmake -G Xcode -DCMAKE_INSTALL_PREFIX=/path/to/geant4.9.6-install /path/to/geant4.9.6
project may be opened with Xcode.
In the CMake GUI, the generator will be asked for the first time you click on Configure button (see Section 2.2), where it can be selected from a drop down list.
Note that in all cases, you can only have one buildtool configuration in a given build directory (e.g. you cannot have Unix Makefiles alongside an Xcode project).
Support for these buildtools is still preliminary, so feedback is welcome, whether bug reports, guides or general comments.
Eclipse projects using Makefiles can be generated via the command:
$ cmake -G"Eclipse CDT4 - <TYPE> Makefiles" <otherargs>
<TYPE> is platform dependent and one
NMake. Note that only a single build mode is
supported here because the projects are Makefile based. This means
that you will need to supply CMake with the command line argument
<MODE>, is the required mode if you
want to change the default mode. By default, Geant4 is built in
With out-of-source builds enforced in Geant4, there are two issues
that need to be worked around due to the way Eclipse expects
project directories to be organised. These are to do with the
integration of version control support and code
editing/navigation/autocompletion. Both issues, together with their
resolution are described in the CMake Wiki entry on Eclipse CDT4 under the
Out-ofSource Builds" section.