# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=kimageannotator
pkgver=0.7.1
pkgrel=0
pkgdesc="Tool for annotating images"
url="https://github.com/ksnip/kImageAnnotator"
arch="all"
license="LGPL-3.0-or-later"
depends_dev="
	kcolorpicker-dev
	qt6-qtbase-dev
	qt6-qtsvg-dev
	qt6-qttools-dev
	"
makedepends="$depends_dev
	cmake
	gtest-dev
	samurai
	"
subpackages="$pkgname-dev"
source="https://github.com/ksnip/kImageAnnotator/archive/v$pkgver/kimageannotator-$pkgver.tar.gz"
builddir="$srcdir/kImageAnnotator-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DBUILD_WITH_QT6=ON \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=TRUE \
		-DBUILD_TESTS=OFF \
		-DBUILD_EXAMPLE=OFF
	# Building tests is currently broken with Qt6
	cmake --build build
}

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

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

	mkdir -p "$pkgdir"/usr/lib/cmake/kImageAnnotator
	ln -s /usr/lib/cmake/kImageAnnotator-Qt5/kImageAnnotator-Qt5Config.cmake \
		"$pkgdir"/usr/lib/cmake/kImageAnnotator/kImageAnnotatorConfig.cmake
	ln -s /usr/lib/cmake/kImageAnnotator-Qt5/kImageAnnotator-Qt5Config-version.cmake \
		"$pkgdir"/usr/lib/cmake/kImageAnnotator/kImageAnnotatorConfig-version.cmake
	ln -s /usr/lib/cmake/kImageAnnotator-Qt5/kImageAnnotator-targets-minsizerel.cmake \
		"$pkgdir"/usr/lib/cmake/kImageAnnotator/kImageAnnotator-targets-minsizerel.cmake
	ln -s /usr/lib/cmake/kImageAnnotator-Qt5/kImageAnnotator-targets.cmake \
		"$pkgdir"/usr/lib/cmake/kImageAnnotator/kImageAnnotator-targets.cmake
}

sha512sums="
cb5e7e87f1b7c72108a8ace7fb60ef644e2de19e78b3e61e50e6d534b235710e5e62464f8d136ee46b7f96cb3235601eb80b09b41d972d8df9ef6fe09cb34c95  kimageannotator-0.7.1.tar.gz
"
