# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=quazip
pkgver=1.4
pkgrel=2
pkgdesc="C++ wrapper for the Gilles Vollant's ZIP/UNZIP C package"
options="!check" # Testsuite only available with qmake not cmake
url="https://github.com/stachenov/quazip"
arch="all"
# Has custom static linking exception
license="LGPL-2.1-or-later WITH custom-static-linking-exception"
makedepends="
	cmake
	qt5-qtbase-dev
	qt6-qtbase-dev
	qt6-qt5compat-dev
	samurai
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	libquazip1-qt5:qt5
	libquazip1-qt6:qt6
	"
source="quazip-$pkgver.tar.gz::https://github.com/stachenov/quazip/archive/v$pkgver.tar.gz"
replaces="quazip-qt5"

build() {
	export CXXFLAGS="$CXXFLAGS -flto=auto"
	export CFLAGS="$CFLAGS -flto=auto"

	cmake -B build-qt5 -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DQUAZIP_QT_MAJOR_VERSION=5

	cmake --build build-qt5

	cmake -B build-qt6 -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DQUAZIP_QT_MAJOR_VERSION=6

	cmake --build build-qt6
}

package() {
	DESTDIR="$pkgdir" cmake --install build-qt5
	DESTDIR="$pkgdir" cmake --install build-qt6
	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}

qt5() {
	pkgdesc="C++ wrapper for the Gilles Vollant's ZIP/UNZIP C package (qt5)"
	replaces="quazip<1.3-r0"

	amove usr/lib/libquazip1-qt5.so.*
}

qt6() {
	pkgdesc="C++ wrapper for the Gilles Vollant's ZIP/UNZIP C package (qt6)"

	amove usr/lib/libquazip1-qt6.so.*
}

sha512sums="
38ce3aa77df1fd92229454e56b7290c066d1e319afa36a9f8ec8477004ae94df682e8f454f13cdaf586a1d0b0e033fe698081033a19536ecd53dd1e4b0204af9  quazip-1.4.tar.gz
"
