# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-other
pkgname=polkit-qt
pkgver=0.200.0
pkgrel=0
pkgdesc="Qt wrapper around polkit-1 client libraries"
arch="all"
url="https://www.kde.org"
license="LGPL-2.1-only"
depends_dev="polkit-elogind-dev"
makedepends="$depends_dev
	cmake
	qt5-qtbase-dev
	qt6-qtbase-dev
	samurai
	"
checkdepends="xvfb-run"
subpackages="$pkgname-dev ${pkgname}5:_qt5 ${pkgname}6:_qt6"
_repo_url="https://invent.kde.org/libraries/polkit-qt-1.git"
source="https://download.kde.org/stable/polkit-qt-1/polkit-qt-1-$pkgver.tar.xz"
builddir="$srcdir/$pkgname-1-$pkgver"
options="!check" # 3 subtests failed in BaseTest

replaces="polkit-qt-1<=0.114.0-r2"

build() {
	cmake -B build-qt5 -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_TEST="$(want_check && echo ON || echo OFF)"
	cmake --build build-qt5

	cmake -B build-qt6 -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DQT_MAJOR_VERSION=6 \
		-DBUILD_TEST="$(want_check && echo ON || echo OFF)"
	cmake --build build-qt6
}

check() {
	xvfb-run -a ctest --test-dir build-qt5/test
	xvfb-run -a ctest --test-dir build-qt6/test
}

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

_qt5() {
	amove usr/lib/libpolkit-qt5*
}

_qt6() {
	amove usr/lib/libpolkit-qt6*
}

sha512sums="
a09214043fa874234086a5de4d27153368dbe775dd6d573dd2531f2f2be79eb22bf73bbfb2a3a839c20c0347762e7af86b73ba38a05b2dcd43e59526e29c008d  polkit-qt-1-0.200.0.tar.xz
"
