# Maintainer: Bruno Pagani <archange@archlinux.org>

pkgname=adios2
pkgver=2.10.0
pkgrel=2
pkgdesc="The Adaptable Input/Output System version 2"
arch=(x86_64 aarch64)
url="https://adios2.readthedocs.io/en/latest/"
license=(Apache)
depends=(blosc bzip2 glibc gcc-libs hdf5 libfabric libpng nlohmann-json
         openmpi pugixml pybind11 sz yaml-cpp zeromq zfp zlib)
# with mgard does not build currently, not time to investigate
makedepends=(cmake gcc-fortran gtest python python-mpi4py python-numpy)
source=(https://github.com/ornladios/ADIOS2/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        https://github.com/ornladios/ADIOS2/commit/f1322a32.patch)
sha256sums=('e5984de488bda546553dd2f46f047e539333891e63b9fe73944782ba6c2d95e4'
            '0a3e95c0b2c6747c6737d181009e120c8b34b869acf029792ebf38be92001c5b')

prepare() {
  patch -d ${pkgname^^}-${pkgver} -p1 < f1322a32.patch # Fix build with external pugixml
}

build() {
  cmake -B build -S ${pkgname^^}-${pkgver} \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DADIOS2_USE_EXTERNAL_DEPENDENCIES=ON \
    -DADIOS2_HAVE_HDF5_VOL=OFF \
    -DADIOS2_BUILD_EXAMPLES=OFF #\
    #-DMGARD_INCLUDE_DIR=/usr/include/mgard
    #-DADIOS2_HAVE_HDF5_VOL needs hdf5-openmpi
  make VERBOSE=1 -C build
}

package() {
  CMAKE_PREFIX_PATH="$pkgdir"/usr/lib/cmake \
  make -C build DESTDIR="${pkgdir}" install
}
