# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Síle Ekaterin Liszka <sheila@vulpine.house>
# Maintainer: Síle Ekaterin Liszka <sheila@vulpine.house>
pkgname=nheko
pkgver=0.12.0
pkgrel=1
pkgdesc="Qt5-based client for Matrix protocol"
url="https://github.com/Nheko-Reborn/nheko"
# armhf blocked by qt5-qtmultimedia
# riscv64: ftbfs
arch="all !armhf !riscv64"
license="GPL-3.0-or-later"
options="!check" # no test suite
depends="
	dbus:org.freedesktop.Secrets
	libsecret
	libnice-gstreamer
	gst-plugins-base
	gst-plugins-good
	gst-plugins-bad
	"
makedepends="
	asciidoctor
	boost-dev
	cmake
	cmark-dev
	gst-plugins-bad-dev
	gst-plugins-base-dev
	gstreamer-dev
	kdsingleapplication-dev
	lmdb-dev
	lmdbxx
	mtxclient-dev
	nlohmann-json
	olm-dev
	openssl-dev>3
	qt6-qtbase-dev
	qt6-qtdeclarative-dev
	qt6-qtmultimedia-dev
	qt6-qtsvg-dev
	qt6-qttools-dev
	qtkeychain-dev
	samurai
	spdlog-dev
	tweeny
	xcb-util-wm-dev
	zlib-dev
	"
subpackages="$pkgname-doc $pkgname-zsh-completion"
source="$pkgname-$pkgver.tar.gz::https://github.com/Nheko-Reborn/nheko/archive/v$pkgver.tar.gz"

prepare() {
	default_prepare
	sed -e '/-Werror/d' \
		-i CMakeLists.txt
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	LDFLAGS="$LDFLAGS -Wl,-z,stack-size=1048576" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_SKIP_RPATH=True \
		-DCMAKE_BUILD_TYPE=None \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ninja -C build check
}

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

sha512sums="
c542592bd8abd2478a7ba8fae99101b14132882ffc1dfe7d1a633b159727f6573a01385a83a44ef0484b0b46363086458da639b5e15706994a79afa6a1a80d29  nheko-0.12.0.tar.gz
"
