# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=stellarsolver
pkgver=2.5
pkgrel=0
pkgdesc="SEP-based star extractor and astrometry.net-based internal astrometric solver"
url="https://github.com/rlancaste/stellarsolver"
arch="all"
license="GPL-3.0-or-later"
makedepends="
	cfitsio-dev
	cmake
	gsl-dev
	qt5-qtbase
	qt5-qtdeclarative-dev
	samurai
	wcslib-dev
"
subpackages="$pkgname-dev"
source="
	https://github.com/rlancaste/stellarsolver/archive/$pkgver/stellarsolver-$pkgver.tar.gz
	0001-don-t-mess-with-qsort_r.patch
"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		$crossopts
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

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

sha512sums="
003522ac0b4130e0ca16ccb617743e3716aa2a182ad63abfb901ea0b47c28a745e8ca1e5b7874d17636ff948b1ebc055277557f89a159e425af7d2a64f513fe8  stellarsolver-2.5.tar.gz
ba7533d00359ecd6b66107aaa264185f2a2830d91d4a2287c5a872d116bbf2b88766859b54c9ab93d9589b01a93582e9b68d52ce5328df1f89aea818ed8e3ab6  0001-don-t-mess-with-qsort_r.patch
"
