Skip to content

C++ integration

After installing HERMES, consume its exported CMake package:

cmake_minimum_required(VERSION 3.20)
project(my_hermes_analysis LANGUAGES CXX)

find_package(Hermes 1 CONFIG REQUIRED)

add_executable(my_analysis main.cpp)
target_link_libraries(my_analysis PRIVATE Hermes::hermes)

Configure the consumer with the installation prefix:

cmake -S . -B build \
  -DCMAKE_PREFIX_PATH=/path/to/hermes/prefix
cmake --build build --parallel

The imported target propagates the public headers, C++17 requirement, GSL, CFITSIO, and FFTW3F when it was part of the HERMES build. Optional HDF5/MPI dependencies are propagated only for an explicit ENABLE_SYS_HDF5=ON build.

Public headers

For broad access:

#include <hermes.h>

For faster and clearer compilation, include the specific public header used:

#include <hermes/cosmicrays/Dragon2D.h>
#include <hermes/integrators/PiZeroIntegrator.h>
#include <hermes/outputs/HEALPixFormat.h>

HERMES uses strongly typed physical quantities. Keep dimensional checks enabled in downstream scientific code.

Package smoke test

The HERMES CI installs to a staging prefix, configures a separate consumer with find_package(Hermes 1 CONFIG REQUIRED), links Hermes::hermes, runs it, and checks installed data resolution. Use the same pattern when packaging HERMES for a new platform.