# Description: PDF rendering library based on xpdf 3.0
# URL: https://poppler.freedesktop.org/
# Maintainer: Juergen Daubert, jue at crux dot nu
# Depends on: fontconfig libjpeg-turbo
# Optional: boost cairo curl gobject-introspection gpgme lcms2 libgd libtiff nss openjpeg2 qt5 qt6-base

name=poppler
version=24.04.0
release=1
source=(https://poppler.freedesktop.org/poppler-$version.tar.xz)

build() {
	prt-get isinst boost || PKGMK_POPPLER+=' -D ENABLE_BOOST=off'
	prt-get isinst gobject-introspection || PKGMK_POPPLER+=' -D ENABLE_GLIB=off'
	prt-get isinst gpgme || PKGMK_POPPLER+=' -D ENABLE_GPGME=off'
	prt-get isinst lcms2 || PKGMK_POPPLER+=' -D ENABLE_LCMS=off'
	prt-get isinst libtiff || PKGMK_POPPLER+=' -D ENABLE_LIBTIFF=off'
	prt-get isinst nss || PKGMK_POPPLER+=' -D ENABLE_NSS3=off'
	prt-get isinst openjpeg2 || PKGMK_POPPLER+=' -D ENABLE_LIBOPENJPEG=none'
	prt-get isinst qt5 || PKGMK_POPPLER+=' -D ENABLE_QT5=off'
	prt-get isinst qt6-base || PKGMK_POPPLER+=' -D ENABLE_QT6=off'

	cmake -S $name-$version -B build -G Ninja $PKGMK_POPPLER \
		-D CMAKE_BUILD_TYPE=Release \
		-D CMAKE_C_FLAGS_RELEASE="$CFLAGS" \
		-D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
		-D CMAKE_INSTALL_PREFIX=/usr \
		-D CMAKE_INSTALL_LIBDIR=/usr/lib \
		-D ENABLE_UNSTABLE_API_ABI_HEADERS=ON \
		-D ENABLE_UTILS=ON \
		-D ENABLE_CPP=ON \
		-D BUILD_CPP_TESTS=OFF \
		-D BUILD_MANUAL_TESTS=OFF \
		-D BUILD_QT5_TESTS=OFF \
		-D BUILD_QT6_TESTS=OFF

	cmake --build build -j ${JOBS:-1}
	DESTDIR=$PKG cmake --install build

	rm -rf $PKG/usr/share/locale
}
