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

_pkgname=CGNS
pkgname=cgns
pkgver=4.5.0
pkgrel=1
pkgdesc="Standard for recording and recovering computer data associated with the numerical solution of fluid dynamics equations"
arch=(x86_64 aarch64)
url="https://cgns.github.io/"
license=(custom)
depends=(tk hdf5 libxmu glu)
makedepends=(gcc-fortran cmake)
options=(!makeflags)
source=(https://github.com/${_pkgname}/${_pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('c72355219318755ba0a8646a8e56ee1c138cf909c1d738d258d2774fa4b529e9')


build() {
    CFLAGS+=" -Wno-implicit-function-declaration -Wno-incompatible-pointer-types" \
    cmake -B build -S ${_pkgname}-${pkgver} \
        -DCGNS_BUILD_CGNSTOOLS=ON \
        -DCGNS_BUILD_SHARED=ON \
        -DCGNS_ENABLE_64BIT=ON \
        -DCGNS_ENABLE_FORTRAN=ON \
        -DCGNS_ENABLE_HDF5=ON \
        -DCGNS_ENABLE_LEGACY=ON \
        -DCGNS_ENABLE_SCOPING=OFF \
        -DCGNS_ENABLE_TESTS=ON \
        -DCMAKE_BUILD_TYPE="Release" \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_SKIP_RPATH=ON
    make -C build
}


check() {
    LD_LIBRARY_PATH="${srcdir}"/build/src/ make -C build test
}

package() {
    make -C build DESTDIR="${pkgdir}" install
    install -Dm644 ${_pkgname}-${pkgver}/license.txt -t "${pkgdir}"/usr/share/licenses/${pkgname}/
    # Remove broken .desktop files
    rm "${pkgdir}"/usr/bin/*.desktop
}
