pkgname=jsoncpp
pkgver=1.9.6
pkgdesc="C++ JSON reader and writer"
homepage="https://github.com/open-source-parsers/jsoncpp/"
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://github.com/open-source-parsers/${pkgname}/archive/${pkgver}.tar.gz")
sha512sums=("006d81f9f723dcfe875ebc2147449c07c5246bf97dd7b9eee1909decc914b051d6f3f06feb5c3dfa143d28773fb310aabb04a81dc447cc61513309df8eba8b08")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  local meson_args=(
    --prefix=/usr
    --buildtype=release
    --wrap-mode=nodownload
    -D python.bytecompile=1
    --includedir include/jsoncpp
    -D tests=true
  )
  meson setup build "${meson_args[@]}"
  meson compile -C build
}

src_check() {
  meson test -C build
}

src_install() {
  meson install -C build --destdir "$pkgdir"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"

  # https://bugs.gentoo.org/941642
  rm -r "${pkgdir}/usr/lib/cmake"
}

# vim:ft=sh syn=sh et sw=2:
