# Contributor: Mark Riedesel <mark@klowner.com>
# Contributor: Leon Marz <main@lmarz.org>
# Maintainer: Leon Marz <main@lmarz.org>
pkgname=opensubdiv
pkgver=3.6.0
_pkgver=${pkgver//./_}
pkgrel=0
pkgdesc="An Open-Source subdivision surface library"
url="https://graphics.pixar.com/opensubdiv"
arch="all !s390x" # ptex isn't available on this arch
license="Apache-2.0"
makedepends="cmake
	doxygen
	glfw-dev
	libxcursor-dev
	libxi-dev
	libxrandr-dev
	onetbb-dev
	opencl-dev
	ptex-dev
	ptex
	py3-docutils
	samurai
	zlib-dev
	"
subpackages="$pkgname-dev $pkgname-tutorials $pkgname-tools"
source="$pkgname-$pkgver.tar.gz::https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v$_pkgver.tar.gz
	0001-cmake-fixes.patch
	"
builddir="$srcdir/OpenSubdiv-$_pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DNO_CLEW=ON \
		-DNO_CUDA=ON \
		-DNO_GLTESTS=ON \
		-DNO_DOC=ON
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

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

tutorials() {
	pkgdesc="$pkgdesc (tutorials)"
	depends="$pkgname"

	mkdir -p "$subpkgdir"/usr/bin/
	local tut; for tut in "$pkgdir"/usr/bin/tutorials/*; do
		mv $tut "$subpkgdir"/usr/bin/opensubdiv_${tut##*/}
	done
	rmdir "$pkgdir"/usr/bin/tutorials
}

tools() {
	pkgdesc="$pkgdesc (tools)"

	amove usr/bin
}

sha512sums="
a976733a26e2c0f6510f59d4372b1b33f5404a9d536bcbd6ae3a1a0ffd1bba5495df7108bebc854d5c069575772c97c0d00f0f16f79e87611376ba84e9ae7a4b  opensubdiv-3.6.0.tar.gz
5ee09848fc078f238f7699066ac2238c83c959d560e9ffc9cbd4e9f8be08b01633eafecb148459deb21d0f13d3e452ee9b122db3fcf2ee25734d494ed5297db9  0001-cmake-fixes.patch
"
