# Contributor: Luca Weiss <luca@lucaweiss.eu>
# Contributor: Duncan Bellamy <dunk@denkimushi.com>
maintainer="fossdd <fossdd@pwned.life>"
pkgname=fmt
pkgver=11.2.0
pkgrel=0
pkgdesc="Open-source formatting library for C++"
url="https://fmt.dev/latest/index.html"
arch="all"
license="MIT"
makedepends="cmake python3 samurai"
subpackages="$pkgname-dev"
source="https://github.com/fmtlib/fmt/releases/download/$pkgver/fmt-$pkgver.zip"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		_cmake_crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	# Build in-tree so the prebuilt docs get installed correctly.
	# See https://github.com/fmtlib/fmt/issues/2837
	cmake -B . -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		$_cmake_crossopts
	cmake --build .
}

check() {
	# libstdc++ locale stuff broken
	ctest -E 'chrono-test|unicode-test|xchar-test'
}

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

sha512sums="
75586d02284a33c0c101b6e78cbb1d61f169610ae9027ddfc20936751a8c2ac4453f3046e7b05fa167a8f8eedeafde0f4cb0bff4f798c17c80994521f660174d  fmt-11.2.0.zip
"
