# Contributor: David Demelier <markand@malikania.fr>
# Maintainer: David Demelier <markand@malikania.fr>
pkgname=adwaita-qt
pkgver=1.4.2
pkgrel=2
pkgdesc="style to bend Qt applications to look like they belong into GNOME Shell"
url="https://github.com/FedoraQt/adwaita-qt"
arch="all"
license="GPL-2.0-only AND LGPL-2.1-only"
makedepends="
	cmake
	qt5-qtbase-dev
	qt5-qtx11extras-dev
	qt6-qtbase-dev
	samurai
	"
subpackages="
	$pkgname-dev
	adwaita-qt5
	adwaita-qt6
	"
source="https://github.com/FedoraQt/adwaita-qt/archive/$pkgver/adwaita-qt-$pkgver.tar.gz"
options="!check"  # no tests provided

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build-qt5 -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DUSE_QT6=OFF \
		$CMAKE_CROSSOPTS
	cmake --build build-qt5
	cmake -B build-qt6 -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DUSE_QT6=ON \
		$CMAKE_CROSSOPTS
	cmake --build build-qt6
}

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

qt5() {
	pkgdesc="$pkgdesc (qt5 plugin)"
	install_if="$pkgname=$pkgver-r$pkgrel qt5-qtbase-x11"

	amove \
		usr/lib/qt5 \
		usr/lib/libadwaitaqt.so.* \
		usr/lib/libadwaitaqtpriv.so.*
}

qt6() {
	pkgdesc="$pkgdesc (qt6 plugin)"
	install_if="$pkgname=$pkgver-r$pkgrel qt6-qtbase-x11"

	amove \
		usr/lib/qt6 \
		usr/lib/libadwaitaqt6.so.* \
		usr/lib/libadwaitaqt6priv.so.*
}

sha512sums="
ef2245cd1b08f2d5c23a534427c7a301cbb3a8b573a1870db48dfc82961417097465e02c696c311e5dd6f9fe1c03a27879c6b08aba5532d2f41ab9d0dcbd7f15  adwaita-qt-1.4.2.tar.gz
"
