# Contributor: Bart Ribbers <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-frameworks-old
maintainer="team/kde <bribbers@disroot.org>"
pkgname=kwindowsystem5
pkgver=5.116.0
pkgrel=0
pkgdesc="Access to the windowing system"
arch="all !armhf" # armhf blocked by extra-cmake-modules
url="https://community.kde.org/Frameworks"
license="MIT AND (LGPL-2.1-only OR LGPL-3.0-only"
depends_dev="qt5-qtx11extras-dev"
makedepends="$depends_dev
	doxygen
	extra-cmake-modules
	libxrender-dev
	qt5-qttools-dev
	samurai
	xcb-util-keysyms-dev
	xcb-util-wm-dev
	"
checkdepends="xvfb-run"
_repo_url="https://invent.kde.org/frameworks/kwindowsystem.git"
source="https://download.kde.org/stable/frameworks/${pkgver%.*}/kwindowsystem-$pkgver.tar.xz"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
builddir="$srcdir/kwindowsystem-$pkgver"

replaces="kwindowsystem<=5.110.0-r0"

build() {
	# Tests require KWINDOWSYSTEM_HAVE_X11
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_QCH=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		-DKWINDOWSYSTEM_HAVE_X11=ON
	cmake --build build
}

check() {
	local skipped_tests="kwindowsystem-(kmanagerselectiontest"
	local tests="
		kstartupinfo_unittest
		kxmessages_unittest
		kkeyserver_x11_unittest
		kwindoweffectstest
		kwindowinfox11test
		kwindowsystemx11test
		kwindowsystem_threadtest
		compositingenabled_test
		"
	case "$CARCH" in
		armv7|ppc64le) tests="$tests
			netrootinfotestwm
			";;
		s390x) tests="$tests
			netrootinfotestwm
			netwininfotestwm
			";;
	esac
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)"
	cd build
	xvfb-run -a ctest -E "$skipped_tests"
}

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

sha512sums="
1b8d45ee0a09161b45f62e6ba4f200f3c2ad937c20eedc03bf65c3a788a5311727ec2a1634db9e1b1208b8ecbe4158273d11c97924a86059a06d3a24d1201157  kwindowsystem-5.116.0.tar.xz
"
