# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
pkgname=lib3mf
pkgver=2.3.0
pkgrel=0
pkgdesc="A C++ implementation of the 3D Manufacturing Format file standard"
url="https://github.com/3MFConsortium/lib3mf"
# "Generating hourglass API bindings and implementation stub" fail on ARM, s390x, and ppc64le
arch="all !armv7 !armhf !aarch64 !s390x !ppc64le !loongarch64"
license="BSD-2-Clause"
subpackages="$pkgname-dev"
makedepends="
	cmake
	libzip-dev
	ninja
	util-linux-dev
	zlib-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/3MFConsortium/lib3mf/archive/v$pkgver.tar.gz"

build() {
	cmake -B build \
		-G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_INCLUDEDIR=include/lib3mf \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DUSE_INCLUDED_ZLIB=OFF \
		-DUSE_INCLUDED_LIBZIP=OFF \
		-DLIB3MF_TESTS=ON
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	# fix Cflags in lib3mf.pc
	sed -e 's!Cflags: -I${includedir}!Cflags: -I${includedir} -I${includedir}/Bindings/C -I${includedir}/Bindings/Cpp!' \
	    -i "$pkgdir"/usr/lib/pkgconfig/lib3mf.pc

	# some packages expect lib3MF.pc instead of lib3mf.pc
	ln -s lib3mf.pc "$pkgdir"/usr/lib/pkgconfig/lib3MF.pc
}

sha512sums="
5bd7ac080905880c14a97211532fe484dce8a07e8444bce0270dd81823afc2247ad1c6770bcdb16ac8723675b49016852f3de887965ee8ec5fd39cc3c8ca31e0  lib3mf-2.3.0.tar.gz
"
