# Contributor: Nick Black <dankamongmen@gmail.com>
# Maintainer: Luca Weiss <luca@lucaweiss.eu>
pkgname=capnproto
pkgver=1.1.0
pkgrel=0
pkgdesc="Tools for working with the Cap'n Proto format"
url="https://capnproto.org/"
arch="all"
license="MIT"
depends_dev="libucontext-dev openssl-dev zlib-dev"
makedepends="$depends_dev cmake linux-headers samurai"
subpackages="$pkgname-dev"
source="https://capnproto.org/$pkgname-c++-$pkgver.tar.gz"
builddir="$srcdir/$pkgname-c++-$pkgver"

case "$CARCH" in
	s390x|armhf|armv7) options="!check";; # FAIL: capnp-test
esac

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build
}

check() {
	ctest
}

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

# We want to move the schema compilers into the dev package.
# See https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#dev.28.29
dev() {
	default_dev

	amove usr/bin
}

sha512sums="
11f58bcaab5a5ffbc9cabecd85e74c37cc8657392d8755709e9e2db84b37379f9084a43e922519a4f975ac0a5438811fb124f715a3a9e5f6293983eb8c3e4581  capnproto-c++-1.1.0.tar.gz
"
