# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: mio <miyopan@e.email>
maintainer="mio <miyopan@e.email>"
pkgname=xournalpp
pkgver=1.2.7
pkgrel=0
pkgdesc="Xournal++ is a handwriting notetaking software with PDF annotation support"
url="https://github.com/xournalpp/xournalpp"
arch="all"
license="GPL-2.0-or-later"
depends="adwaita-icon-theme"
makedepends="
	cmake
	glib-dev
	gtest-dev
	gtk+3.0-dev
	gtksourceview4-dev
	help2man
	librsvg-dev
	libsndfile-dev
	libx11-dev
	libxi-dev
	libxml2-dev
	libzip-dev
	lsb-release
	lua5.4-dev
	poppler-dev
	portaudio-dev
	samurai
	"
options="!check" # 2 failed unit tests
subpackages="$pkgname-dbg $pkgname-doc $pkgname-lang"
source="xournalpp-$pkgver.tar.gz::https://github.com/xournalpp/xournalpp/archive/v$pkgver.tar.gz
	no-execinfo.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi

	# Increase stack-size to avoid crashes when using pen for input
	LDFLAGS="$LDFLAGS -Wl,-z,stack-size=2097152" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DLUA_LIBRARIES="/usr/lib/lua5.4/liblua.so" \
		-DENABLE_GTEST=on \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$CMAKE_CROSSOPTS
	cmake --build build --target all translations
}

check() {
	cmake --build build --target test-units
	cmake --build build --target test
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm0644 LICENSE "$pkgdir"/usr/share/licenses/xournalpp/LICENSE
}

sha512sums="
cbec828769405ccbe753e63279c3faabf253678543281c9da8ea67e665bafac43cebcd50a5d6588a123c6956e9d672be25e66a2231e9d44fa0640a379eabb70c  xournalpp-1.2.7.tar.gz
1046141c3b51286fee439b4bba1ea247e7d121054b64134eecfb5859932d55d5afbf617052502bd7ca110928122b9690d463d579ed1575cf37b52ce318b087ca  no-execinfo.patch
"
