![]() |
ORB5
4.00
|
How to compile the code using CMake and its presets.
ORB5 can be compiled with CMake as an alternative to the Makefile-based build described in Get started. CMake handles configuration, dependency discovery and compiler-specific flags automatically, and ships a set of presets covering the most common configurations.
As for the Makefile build, these are normally provided by environment modules, which must be loaded before configuring (see Required modules).
Building with CMake is a two-step process. First configure the project into a build directory. From the ORB5 root directory:
then build it:
Configuration is done only once per build directory. While developing, simply rerun the build command after editing the sources. There is no need to reconfigure. The resulting binaries (orb5 and pszs_offline) are placed in build/release/bin/.
Note that build/release is a name chosen arbitrarily. You could use whichever name fits best for your build directory. It must however match between the configure and build steps.
Options are passed at configure time with -D<OPTION>=<VALUE>:
| Option | Default | Description |
|---|---|---|
| CMAKE_BUILD_TYPE | (none) | Debug or Release |
| USE_OPENMP | OFF | Enable OpenMP hybrid parallelism |
| USE_OPENACC | OFF | Enable GPU offload via OpenACC (NVHPC only) |
| USE_MPI_F08 | auto | Use the mpi_f08 interface (recommended). Detected at configure time. |
| GPU_CC | 90 | GPU compute capability: 80=A100, 90=H100, 100=B200 |
For example, to build an optimized GPU version for an H100 with the NVHPC compiler:
Rather than remembering option combinations, you can use the presets bundled in CMakePresets.json. List them with:
Configure and build a preset without any -D flags:
Each preset configures into its own build/<preset-name>/ directory, so several configurations can coexist. The available presets are:
| Preset | Build type | Parallelism / target |
|---|---|---|
| debug / release | Debug / Release | MPI only |
| debug-mt / release-mt | Debug / Release | MPI + OpenMP |
| debug-gpu-h100 / release-gpu-h100 | Debug / Release | MPI + OpenMP + OpenACC on H100 (NVHPC) |
The GPU presets automatically select the NVHPC compiler. On the other hand, the CPU presets use whichever compiler your loaded environment provides.
A workflow chains the configure and build steps into a single command:
Use a workflow for the first build, for continuous integration or when you just want a binary in one shot. Use the two-step configure/build (see Using presets) for the iterative development loop, where you configure once and rebuild many times without reconfiguring.
Site- or user-specific overrides (absolute compiler paths, non-standard dependency locations, ...) can be placed in a CMakeUserPresets.json file at the root of the repository. This file is not tracked by git and can define presets that inherit the shared ones while overriding individual cache variables.