# Contributor: Mark Riedesel <mark@klowner.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=yaml-cpp
pkgver=0.8.0
pkgrel=0
pkgdesc="YAML parser and emitter in C++ matching YAML 1.2 spec"
url="https://github.com/jbeder/yaml-cpp"
arch="all"
license="MIT"
checkdepends="gtest-dev"
makedepends="cmake samurai"
subpackages="$pkgname-dev"
source="https://github.com/jbeder/yaml-cpp/archive/$pkgver/yaml-cpp-$pkgver.tar.gz
	enable-pic.patch
	unbundle-gtest.patch
	testsuite-gcc13.patch
	"

prepare() {
	default_prepare

	# Remove bundled gtest.
	rm -rf test/gtest-*
}

build() {
	local _build_tests=ON
	if ! want_check; then
		_build_tests=OFF
	fi

	cmake -B build -G Ninja . \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_VERBOSE_MAKEFILE=ON \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DYAML_BUILD_SHARED_LIBS=ON \
		-DYAML_CPP_BUILD_TESTS=$_build_tests
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

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

sha512sums="
aae9d618f906117d620d63173e95572c738db518f4ff1901a06de2117d8deeb8045f554102ca0ba4735ac0c4d060153a938ef78da3e0da3406d27b8298e5f38e  yaml-cpp-0.8.0.tar.gz
c9179e8dd0bdad1ca1a749f72cff14de923b1a5960287834fc0ab8dc068aa7222b740a103c100b5b63769349ffd5965f6b2ce843c8d3aa12ac4ba03e8457f389  enable-pic.patch
cafd14349864bbbd00298c9208dcf7e9a7612b983994be3af1dd852f127906dc8026e6e7dafb86eabf1bcad51f9e614c7f37265463a1c0fd77ea2af7866dc305  unbundle-gtest.patch
1eac35b15a230b02ab62b8f565b5097d4e90c6e61d821fff4d27ca256f83bb44f7d09caa037823116c42c53113b017ae1d54d7419b3f2debff0583321077868a  testsuite-gcc13.patch
"
