# Contributer: Reza Tavakoli <rta.0070@gmail.com>

pkgbase=libcbor
pkgname=("${pkgbase}" "${pkgbase}-devel")
pkgver=0.12.0
pkgrel=1
pkgdesc="A C library for parsing and generating CBOR, a general-purpose schema-less binary data format"
arch=('i686' 'x86_64')
url="https://github.com/PJK/libcbor"
license=('spdx:MIT')
makedepends=("cmake" "ninja" "gcc")
source=(https://github.com/PJK/libcbor/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('5368add109db559f546d7ed10f440f39a273b073daa8da4abffc83815069fa7f')

build() {
  cmake \
    -GNinja \
    -Bbuild \
    -S "${pkgname}-${pkgver}" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCBOR_CUSTOM_ALLOC=ON \
    -DBUILD_SHARED_LIBS=ON \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5
  cmake --build build
  DESTDIR="${srcdir}/dest" cmake --install build
}

package_libcbor() {
  groups=("libraries")
  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
}

package_libcbor-devel() {
  pkgdesc="Development headers and library for libcbor"
  depends=("$pkgbase=$pkgver")
  groups=("development")
  mkdir -p ${pkgdir}/usr/lib
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr
}
