# Contributor: Síle Ekaterin Liszka <sheila@vulpine.house>
# Maintainer: Síle Ekaterin Liszka <sheila@vulpine.house>
pkgname=kdsingleapplication
pkgver=1.1.0
pkgrel=0
pkgdesc="Helper class for single-instance policy applications"
url="https://www.kdab.com"
arch="all"
license="MIT"
makedepends="cmake samurai qt6-qtbase-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/KDAB/KDSingleApplication/releases/download/v$pkgver/kdsingleapplication-$pkgver.tar.gz"

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 \
		-DKDSingleApplication_QT6=true \
		-DKDSingleApplication_TESTS=true \
		$crossopts
	cmake --build build
}

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

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

sha512sums="
61b34a36b05c58ede881f38d78c767726f8e23dc230e292568013fa428f50ff674f7eb12bc4d76ceaa9ef444264b2e86d95ab14cc41c6a275bf917edb8832c1f  kdsingleapplication-1.1.0.tar.gz
"
