# Template file for 'occt'
pkgname=occt
version=7.9.3
revision=1
_gittag="V${version//./_}"
build_style=cmake
configure_args="-DUSE_FREEIMAGE=ON -DUSE_VTK=OFF -DINSTALL_SAMPLES=ON -DUSE_TBB=ON"
makedepends="freetype-devel glu-devel freeimage-devel tcl-devel tk-devel tbb-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://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/${_gittag}.tar.gz"
checksum=5ecf094ec6b12d5413dfb851d8c3590c354058aee556e32e408bdfbf8c357d57
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"
	}
}
