# Maintainer: Maksim Bondarenkov <maksapple2306@gmail.com>

_realname=tomlplusplus
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.4.0
pkgrel=2
pkgdesc="Header-only TOML config file parser and serializer for C++17 (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://marzer.github.io/tomlplusplus/"
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/marzer/${_realname}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        0001-tomlplusplus-fix-cmake-imported-location.patch)
sha256sums=('8517f65938a4faae9ccf8ebb36631a38c1cadfb5efa85d9a72e15b9e97d25155'
            '8042359f9a9eb7244e137fff8e8e54c2b877fc5e5430aae82dd56a07499f7cec')

prepare() {
  cd "${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}"/0001-tomlplusplus-fix-cmake-imported-location.patch
}

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    meson setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      "build-${MSYSTEM}" \
      "${_realname}-${pkgver}"

  meson compile -C "build-${MSYSTEM}"
}

package() {
  meson install -C "build-${MSYSTEM}" --destdir "${pkgdir}"

  install -Dm644 "${_realname}-${pkgver}/LICENSE" -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}
