# Template file for 'occt'
pkgname=occt
version=7.7.1
revision=1
_gittag="V${version//./_}"
build_style=cmake
# XXX: re-enable -DUSE_TBB=ON if possible when updating
configure_args="-DUSE_FREEIMAGE=ON -DUSE_GL2PS=ON -DUSE_VTK=OFF
 -DINSTALL_SAMPLES=ON"
makedepends="freetype-devel glu-devel freeimage-devel gl2ps-devel tcl-devel
 tk-devel"
short_desc="OpenCASCADE Technology - library for CAD/CAM/CAE applications"
maintainer="Piraty <mail@piraty.dev>"
license="custom:LGPL-2.1-only-with-exceptions"
homepage="https://www.opencascade.com"
# distfile: use git instead of official tarball, which requires registration
# see https://www.opencascade.com/content/packaging-again-debian
distfiles="https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=refs/tags/${_gittag};sf=tgz>occt-${_gittag}.tar.gz"
checksum=f413d30a8a06d6164e94860a652cbc96ea58fe262df36ce4eaa92a9e3561fd12
conflicts="oce>=0"
if [ "$XBPS_TARGET_LIBC" = musl ]; then
	makedepends+=" libexecinfo-devel"
	configure_args+=" -DCMAKE_CXX_STANDARD_LIBRARIES=-lexecinfo"
fi

pre_build() {
	cp build/OpenCASCADECompileDefinitionsAndFlags-release.cmake \
		build/OpenCASCADECompileDefinitionsAndFlags-none.cmake
}

post_install() {
	rm ${PKGDESTDIR}/usr/share/doc/opencascade/*_LGPL_*.txt
	vlicense OCCT_LGPL_EXCEPTION.txt
	rm ${DESTDIR}/usr/bin/custom*.sh

	vmkdir /etc/profile.d
	vinstall ${FILESDIR}/opencascade.sh 644 /etc/profile.d
	chmod 755 ${DESTDIR}/usr/bin/draw.sh
}

occt-devel_package() {
	short_desc+=" - development files"
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.so"
		vmove "usr/lib/cmake"
		vmove "usr/share/opencascade/samples"
	}
}
