1 How to build and use the Gaudi with CMake {#quick-guide-cmake}
2 =========================================
6 The CMake configuration of Gaudi is based on the version 2.8.5 or later of
7 CMake. On lxplus (SLC5 and SLC6) you need to call:
9 $ export PATH=/afs/cern.ch/sw/lcg/contrib/CMake/2.8.9/Linux-i386/bin:$PATH
11 You also need to ensure that the compiler you want to use is configured and
12 available on the PATH, for example with something like:
14 $ . /afs/cern.ch/sw/lcg/contrib/gcc/4.9.3/x86_64-slc6/setup.sh
16 **NOTE**: If you use the LHCb environment (as of LbScripts v7r7), you do not
17 need to prepare the environment for the compiler.
21 To quickly get started, you can use the Makefile `Makefile-cmake.mk`, which
22 will take care of the main details (except the value of `BINARY_TAG`, or
23 `CMTCONFIG` for backward compatibility):
25 $ make -f Makefile-cmake.mk -j 8
26 $ make -f Makefile-cmake.mk test
32 just run CMake to generate the build directory (or reconfigure)
36 build everything (implies `configure`)
40 run the tests (and generate HTML reports), note that it does not
41 imply the build and does not require installation
45 populate the `InstallArea` directory, *required for runtime/deployment*
47 Some extra targets are provided for special cases:
51 allow partial installation after a failed build (for builds in a
52 continuous integration system)
56 optional operations on the content of `InstallArea` (like compressing
57 the `python` directory)
62 I suggest to use the off-source build, which means that the files required by
63 the build and the build products are created in a different directory than the
65 In this example I'll use `Gaudi.build`, created at the same level as the
66 directory containing the sources (`Gaudi.src`).
68 To prepare the build directory, you have to:
73 $ cmake -DCMAKE_TOOLCHAIN_FILE=$src/toolchain.cmake \
74 -G "Eclipse CDT4 - Unix Makefiles" $src
76 This will create the required Unix makefiles and the Eclipse project
77 configuration to build Gaudi.
79 Other options are available on the command line when you prepare the build
80 directory the first time or afterwards via the CMake configuration tool
81 `ccmake`, for example `CMAKE_USE_DISTCC` or `CMAKE_USE_CCACHE`.
83 Now you can build the project with a simple (from `Gaudi.build`)::
87 or from Eclipse after you imported the project.
89 The tests can be run via the command `ctest` or with `make test`.
91 Note that the build via `Makefile-cmake.mk` uses the build directory
92 `build.$BINARY_TAG` under the source directory.
97 The build of the project obtained with CMake cannot be used directly by other
98 projects: it needs to be installed in the source directory (for backward
99 compatibility with CMT) with the command:
103 It must be noted that the special file ``python.zip`` is not automatically
104 generated, so, if you want it, you have to call, after the installation:
111 The runtime environment for the installed binaries is described by the XML file
112 `Gaudi.xenv` located in the directory `InstallArea/$BINARY_TAG`, in
113 the format understood by the Python script `xenv` available in the `cmake`
114 directory in the source tree (it is also installed).
116 The behavior of `xenv` is quite similar to that of the standard Unix
117 command `env` (see `man env`), with the addition of few functionalities
118 (append, prepend, XML).
120 For example, you can call `gaudirun.py` like this (with the variable `src`
123 $ $src/cmake/xenv --xml $src/InstallArea/$BINARY_TAG/Gaudi.xenv \
126 or, to have a sub-shell with the right environment:
128 $ $src/cmake/xenv --xml $src/InstallArea/$BINARY_TAG/Gaudi.xenv bash
130 (note that you may need to add the `--norc` option to `bash`).
133 Run from the build directory
134 ----------------------------
135 For testing and debugging (as already mentioned) there is no need to install.
137 To run an application using the build directory, you can use the script
138 `xenv` with the XML file `Gaudi-build.xenv` located in the `conf` subdirectory
139 of the build directory, or the convenience script `run` (in the build directory),
140 for example like this:
143 $ ./run gaudirun.py --help
146 When using `Makefile-cmake.mk` the above lines should be changed in
148 $ build.$BINARY_TAG/run gaudirun.py --help
149 $ build.$BINARY_TAG/run bash
154 * [CMake documentation](http://www.cmake.org/cmake/help/documentation.html)
155 * `FindTBB.cmake` was taken from <https://bitbucket.org/sergiu/tbb-cmake>