CMake Configuration
CMake Configuration
Build system of MpdRoot is currently set-up using CMake. Minimal steps needed (provided one has all relevant dependencies installed) are
mkdir build && cd build # create and enter build directory
export MPDROOT=~/tmp/mpdroot # where MpdRoot will be installed (compulsory)
cmake .. # configure build
make [-j XX] install # build and install MpdRoot - -j XX run build in paralell on XX cores
cmake tries to find all dependencies and if some of them are missing, it provides users with information, which packages were not found and need to be added. Please note, if you are using NICADist as a source of packages, adding module mpddev should be sufficient for basic MpdRoot build.
Additional packages
Multiple additional packages can be added to MpdRoot using certain flags. When user enables given option, it is his responsibility to make requested external packages available prior to CMake configuration. If given package is not available, configuration will terminate with error. To request certain package, add in configuration step -D[option]=yes
| Option | Description | NICADist module |
|---|---|---|
| ENABLE_ACTS | Add support for Acts and build MpdActs library | ACTS |
| ENABLE_FFTW3 | Add support for FFTW3. Path to FFTW3 library and includes will be added to environment variables. Currently we have no code using FFTW3. | FFTW |
| ENABLE_LIBTORCH | Add support for LibTorch in order to enable integration of PyTorch-created models. Currently we have no code using LibTorch. | LibTorch |
| ENABLE_MXPFIT | Add support for mxpfit. Currently we have no code using mxpfit. It is used only in physics analysis. | mxpfit |
| ENABLE_ONNX_RUNTIME | Add support for ONNXRuntime. | ONNXRuntime |
| ENABLE_XGBOOST | Add support for XGBoost. While supported, XGBoost is deprecated in favor of more flexible ONNXRuntime. | XGBoost |
Using Ninja as build system
Normal build consists of calling cmake followed by make. To make build faster it is possible to use ninja as a basic build system. To make it work, one has to modify configuration and build steps:
export NINJA_STATUS="[%p] " # optional, nicer output during build
cmake -G Ninja -DCMAKE_COLOR_DIAGNOSTICS=ON [usual_cmake_options] .. # use Ninja and color output
ninja install
If using NICADist - module add ninja.
Testing
Since testing in MpdRoot is work in progress, only small portion of code is covered by tests. This description is rather about available infrastructure. Currently have 3 layers of tests:
- Build tests - Macros are built during MpdRoot compilation. This tests are compulsory and can't be configured. Each macro must compile and have
mainfunction. - Execution tests - Enabled via
ENABLE_TESTSoption. These tests run macros from Build tests (see point 1). Some of the tests require special input data files provided viaMPDROOT_DATAvariable (see below). - Unit tests - Enabled via
ENABLE_TESTSoption. This tests requireCatch2framework to be available. If using NICADist -module add Catch2.
For details on testing see Testing.
Static analysis (WIP)
For static analysis we will use Clang Tidy, Cppcheck, and Include-What-You-Use (IWYU). To enable individual tools for static analysis, use following switches
| Option | Description | NICADist module |
|---|---|---|
| ENABLE_CLANG_TIDY | Enable static analysis using Clang Tidy | Clang |
| ENABLE_CPPCHECK | Enable static analysis with include-what-you-use | Cpptest |
| ENABLE_INCLUDE_WHAT_YOU_USE | Enable static analysis with cppcheck | Clang |
| ENABLE_STATIC_ANALYSIS | If set to true, all available types of static analysis will be enabled | see above |
For details on static analysis see Static analysis.
Special options
| Option | Description |
|---|---|
| INSTALL_ALIGNMENT | If set to yes, alignment library MpdTpcAlignment will be installed. If not set, or set to no, MpdTpcAlignment library will be only built to ensure it works with latest sources of MpdRoot. |
Complete example
This example is for information only. One does not need to use all options. It is for reference only, therefore all options are disabled by default. Ninja is used as build system and it is expected, that user has already installed/loaded all necessary packages.
mkdir build && cd build
export MPDROOT=~/tmp/mpdroot
export MPDROOT_DATA=~/git/jinr/mpd/mpdroot/data
export NINJA_STATUS="[%p] "
cmake -G Ninja -DCMAKE_COLOR_DIAGNOSTICS=ON -DENABLE_ACTS=OFF -DENABLE_FFTW3=OFF -DENABLE_LIBTORCH=OFF -DENABLE_MXPFIT=OFF -DENABLE_ONNX_RUNTIME=OFF -DENABLE_XGBOOST=OFF -DENABLE_TESTS=OFF -DINSTALL_ALIGNMENT=OFF -DENABLE_CLANG_TIDY=OFF -DENABLE_CPPCHECK=OFF -DENABLE_INCLUDE_WHAT_YOU_USE=OFF
ninja install