# Contributor: Clayton Craft <clayton@craftyguy.net>
maintainer="team/kde <clayton@craftyguy.net>"
pkgname=kstars
pkgver=3.7.6
pkgrel=0
pkgdesc="Astronomy software"
url="https://kde.org/applications/education/kstars"
# arm, riscv64: no support in deps
# ppc64le: build fails and I don't care about that arch
# x86: stellarsolver segfaults
arch="all !armv7 !armhf !ppc64le !riscv64 !x86"
license="GPL-2.0-or-later"
makedepends="
	cfitsio-dev
	cmake
	curl-dev
	eigen-dev
	extra-cmake-modules
	gsl-dev
	kconfig5
	kconfigwidgets5
	kcoreaddons5
	kcrash5
	kdoctools5-dev
	ki18n5
	kio5
	knewstuff5-dev
	knotifications5
	knotifyconfig5-dev
	kplotting5-dev
	kwidgetsaddons5
	kxmlgui5
	libindi-dev
	libnova-dev
	libraw-dev
	libxisf-dev
	qt5-qtbase-dev
	qt5-qtdatavis3d-dev
	qt5-qtdeclarative-dev
	qt5-qtquickcontrols2-dev
	qt5-qtsvg-dev
	qt5-qtwebsockets-dev
	qtkeychain-dev
	samurai
	stellarsolver-dev
	wcslib-dev
"
subpackages="$pkgname-dev $pkgname-doc"
source="
	https://download.kde.org/stable/kstars/$pkgver/kstars-$pkgver.tar.xz
	tests-disable-ngc4535-autofocus3.patch
	"

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

check() {
	case "$CARCH" in
	loongarch64)
		# TODO: test times out due to network issues, try again when builders reach EU
		_skip_tests="|TestKSUserDB"
		;;
	esac

	# Note: excluded tests fail because they cannot find TZrules.dat and other
	# things in the 'data' dir. Seems like test framework would allow
	# specifying or overriding the search dir since data is in $srcdir, but I
	# couldn't figure it out yet, so disabling tests...
	ctest --test-dir build \
		-E "StarCorrespondenceTest|Test(ArtificialHorizon|CatalogDownload|EkosCapture|EkosFilterWheel|EkosFocus|EkosMeridianFlipState|EkosMount|EkosScheduler|EkosSchedulerOps|EkosSimulator|KSPaths|PolarAlign)$_skip_tests"
}

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

sha512sums="
9269c61062f4cbfaee0aefb6ef3392c01e9f30ffe367cd1b536ab7114500b0a30421e5bc9e599b573adf8ea1b6c67ff4c4562ba7638739d0cc9e27f0e2979efa  kstars-3.7.6.tar.xz
218371075ce851dd3d0b96731a8360859a60fef83bde1108485b8ea0b84221e77a982185eb74b34c43390e988b3f3ef82864cd4eee91023a904421218d278ae1  tests-disable-ngc4535-autofocus3.patch
"
