# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-other
pkgname=qca
pkgver=2.3.9
pkgrel=0
pkgdesc="Qt cryptographic architecture"
url="https://userbase.kde.org/QCA"
arch="all"
license="LGPL-2.1-or-later"
depends_dev="
	cyrus-sasl-dev
	qt5-qtbase-dev
	"
makedepends="$depends_dev
	cmake
	doxygen
	graphviz
	openssl-dev>3
	qt6-qt5compat-dev
	qt6-qtbase-dev
	samurai
	"
subpackages="$pkgname-qt6-dev:dev_qt6 $pkgname-dev $pkgname-doc lib$pkgname-qt5:libs_qt5 lib$pkgname-qt6:libs_qt6"
_repo_url="https://invent.kde.org/libraries/qca.git"
source="https://download.kde.org/stable/qca/$pkgver/qca-$pkgver.tar.xz"

build() {
	cmake -B build-qt5 -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_cyrus-sasl_PLUGIN=yes \
		-DQT6=OFF
	cmake -B build-qt6 -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_cyrus-sasl_PLUGIN=yes \
		-DQT6=ON

	cmake --build build-qt5
	cmake --build build-qt6
}

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

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

dev_qt6() {
	depends="
		cyrus-sasl-dev
		qt6-qt5compat-dev
		qt6-qtbase-dev
		"
	amove usr/include/Qca-qt6
	amove usr/lib/cmake/Qca-qt6
	amove usr/lib/libqca-qt6.so
}

libs_qt5() {
	amove usr/lib/qca-qt5
	amove usr/lib/libqca*qt5*
}

libs_qt6() {
	amove usr/lib/qca-qt6
	amove usr/lib/libqca*qt6*
}

sha512sums="
025ef203c66e413a9c93d7e0e5449d8a23fb6bb27b2f1c4f137173e33b8c17ff6dec794c8349b6b37ee9d7fffe23875a2cf7cf6592efc373f1aac9230f83aa06  qca-2.3.9.tar.xz
"
