# Maintainer: Simon Zeni <simon@bl4ckb0ne.ca>
pkgname=glm
pkgver=0.9.9.8
pkgrel=4
pkgdesc="C++ mathematics library for graphics programming"
url="https://glm.g-truc.net/"
arch="noarch"
license="MIT"
makedepends="cmake samurai"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/g-truc/glm/archive/refs/tags/$pkgver/glm-$pkgver.tar.gz
	fix-endian-test.patch
	glm.pc
	$pkgname-generate-glm-target.patch::https://github.com/g-truc/glm/commit/6059c5767b8be1fdaf7b4c8bf6f435ee9f7e5f0c.patch
	$pkgname-generate-glmConfigVersion.patch::https://github.com/g-truc/glm/commit/6c9d74c3e08463f6cac06280e14c4610ff5bb05f.patch
	"
patch_args="--binary -p1"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DGLM_TEST_ENABLE=TRUE
	cmake --build build
}

check() {
	ctest --output-on-failure --test-dir build \
		-E 'test-core_func_integer'
}

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

	mkdir -p "$pkgdir"/usr/share/doc
	cp -r doc "$pkgdir"/usr/share/doc/glm
	mkdir -p "$pkgdir"/usr/lib/pkgconfig
	cp "$srcdir"/glm.pc "$pkgdir"/usr/lib/pkgconfig/
}

sha512sums="
9484b0c12175414237c5b9486a2990099b1cb727e442f25ecda18b081aa661f7e92a44481f642989553cd3da7992a773441ee5688991bd539ce19fb66a5ce9e8  glm-0.9.9.8.tar.gz
93e02285b7530bb5fdad71905a55150e64cda3d036f43fca166eddb2e8d2f2d03025543c96dfd44234a37f860ea0682be2c683a66c9d4ef33f5bc269c95bbdfa  fix-endian-test.patch
185a9eae06b4bd291c72351239a969e37b83feb1b2de64c397f657370aff81241bf489f0109c74d50cd7106389c2740b0f620f39cdd3604dc51ed9b5046442af  glm.pc
540bac4736bdda2b66fb64aba93893fab1226f86f4fe3b584a7a6013fd36d7eca9f897543116d0396d3181afb298676ab3fa585ccec83c98fdc670d48d2d2c7a  glm-generate-glm-target.patch
dd25f76475171ff055222c3502993efc34420f0edb2e30875fbb5d981ff4ffd8a1a095cacb18f92335a69cc0c1ca3b6cb311488f0bdd5c7a9a5db07ddfb75533  glm-generate-glmConfigVersion.patch
"
