# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=cppdap
pkgver=1.58.0
pkgrel=1
pkgdesc='C++ library for the Debug Adapter Protocol'
arch=(x86_64 aarch64)
url='https://github.com/google/cppdap'
license=(Apache)
depends=(gcc-libs)
makedepends=(cmake nlohmann-json)
source=(https://github.com/google/cppdap/archive/dap-$pkgver-a.tar.gz
        https://github.com/google/cppdap/commit/6a3cc9a8.patch)
sha256sums=('5d35ca5db78570b6bef698e3365f79bd82a4f78e8393546387f78d7bdb2a2a08'
            '7c1bed285d8bb2400ae46def282a4736b9afcb74bb3e96663fac97b73dea3cb4')

prepare() {
  patch -d cppdap-dap-$pkgver-a -p1 < 6a3cc9a8.patch # Build shared lib
}

build() {
  cmake -B build -S cppdap-dap-$pkgver-a \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCPPDAP_USE_EXTERNAL_NLOHMANN_JSON_PACKAGE=ON \
    -DBUILD_SHARED_LIBS=ON
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
