# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=nuspell
pkgver=5.1.6
pkgrel=0
pkgdesc="Free and open source C++ spell checking library"
url="https://nuspell.github.io/"
arch="all"
license="LGPL-3.0-or-later"
makedepends="cmake icu-dev ronn samurai"
checkdepends="catch2 icu-data-full"
subpackages="$pkgname-dev $pkgname-libs $pkgname-doc"
source="https://github.com/nuspell/nuspell/archive/v$pkgver/nuspell-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi

	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		-DBUILD_DOCS=OFF \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest --test-dir build
}

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

sha512sums="
ab6d9394a55d9a2a347ccae47aeef6a96af70f421ad6ea8f7ac7fde2052790f37fb1c7ec3112daac7600d193430a560cb1915ab6557c9353717f65cb32f13ab8  nuspell-5.1.6.tar.gz
"
