if(NOT MBX)
  return()
endif()

# Case TOMLs own the method, cell, bead count and finite-difference step.
function(add_mbx_derivative_case case fixture json boundary quantity timeout)
  math(EXPR runtime_timeout "${timeout} - 60")
  add_derivative_test("mbx.${case}"
    "${CMAKE_CURRENT_SOURCE_DIR}/${fixture}"
    "${CMAKE_CURRENT_BINARY_DIR}/mbx.${case}"
    MODE mpi MPI_RANKS 1 THREADS 1
    RUNTIME_TIMEOUT ${runtime_timeout} TIMEOUT ${timeout}
    LABELS mbx integration ${boundary} ${quantity}
    ENVIRONMENT "OMP_NUM_THREADS=1"
    OPTIONS "--runtime-file=mbx.json=${CMAKE_CURRENT_SOURCE_DIR}/${fixture}/${json}"
      "--runtime-file=pimd.toml=${CMAKE_CURRENT_SOURCE_DIR}/cases/${case}.toml"
      --check-input)
endfunction()

# TESTVIRIAL is defined only for periodic boundaries. The full ice fixture
# exposes a PME virial discrepancy that the trimer did not reveal.
add_mbx_derivative_case(isolated_force trimer mbx.json isolated force 240)
add_mbx_derivative_case(periodic_force trimer periodic.json periodic force 240)
add_mbx_derivative_case(periodic_virial trimer periodic.json periodic virial 240)
add_mbx_derivative_case(pme_force trimer pme.json pme force 240)
add_mbx_derivative_case(ice_pme_virial ice mbx.json pme virial 600)
