# Contributor: Luca Weiss <luca@lucaweiss.eu>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=fmt
pkgver=10.2.1
pkgrel=2
pkgdesc="Open-source formatting library for C++"
url="https://fmt.dev/latest/index.html"
arch="all"
license="MIT"
makedepends="cmake doxygen python3 samurai"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/fmtlib/fmt/releases/download/$pkgver/fmt-$pkgver.zip
	Fix-handling-of-static-separator.patch"

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="
1cf0e3dd09c7d87e0890b8743559159d3be2a8f33c135516962d17c4eeb7b00659e6acd74518bd5566ee4e83ddaba155fecb4c229f90cd258b3b832e72ad82cd  fmt-10.2.1.zip
695fb13dc60eea6ce83319d8925be49b3a7af6651d80ab528ed244e589c581ee05ac7887f6c73dbfcf2654afabd2c405c0e2eeb5f1f0851237b14d305185d7d5  Fix-handling-of-static-separator.patch
"
