# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=openapv
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.2.0.4
pkgrel=1
pkgdesc='The reference implementation of the APV codec (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/AcademySoftwareFoundation/openapv/'
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake")
source=("https://github.com/AcademySoftwareFoundation/openapv/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('1d8d31b0758d4b968d9b2ab483b3edb6de3440edcb27f14801ef42d6f2368e55')

build() {
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  cmake -B build -S "${_realname}-${pkgver}" \
    -G 'Ninja' \
    -DCMAKE_BUILD_TYPE='None' \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    -DOAPV_APP_STATIC_BUILD='OFF' \
    -DCMAKE_DLL_NAME_WITH_SOVERSION=ON \
    -Wno-dev
  cmake --build build
}

package() {
  DESTDIR="${pkgdir}" cmake --install build
  install -D -m644 "${_realname}-${pkgver}/LICENSE" -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}
