# Contributor: Andrew Bell <andrew.bell.ia@gmail.com>
# Maintainer: Andrew Bell <andrew.bell.ia@gmail.com>
pkgname=xerces-c
pkgver=3.2.5
pkgrel=2
pkgdesc="A validating XML parser written in a portable subset of C++"
url="https://xerces.apache.org/index.html"
arch="all"
license="Apache-2.0"
makedepends="cmake curl-dev icu-dev samurai"
subpackages="$pkgname-samples $pkgname-doc $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/apache/xerces-c/archive/v$pkgver.tar.gz
	c++17.patch
	"

# secfixes:
#   3.2.5-r0:
#     - CVE-2018-1311

build() {
	local thread_support=-Dthreads:BOOL=ON
	case "$CARCH" in
		s390x) thread_support=-Dthreads:BOOL=OFF ;;
	esac
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		$thread_support \
		-Dnetwork-accessor=curl \
		-Dmessage-loader=icu \
		-Dtranscoder=icu \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	ctest
}

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

samples() {
	pkgdesc="$pkgdesc (compiled samples)"

	amove usr/bin
}

sha512sums="
55bf16456408af7c5aa420a55b27555889fc102a24e86aecb918c165acc80bbc344420687061e020fe223ea04dd78bef929ceedc4b3e24727787f12b8d79b610  xerces-c-3.2.5.tar.gz
e67dc17892305d4dc8e1a409ab0ed1b62c242c4bead55946a629ba4e01da4cb6067c880c62e61550a529f00963c45951e00fb942ef693cd4a843cb77ec22415b  c++17.patch
"
