SUMMARY="Small, safe and fast formatting library"
DESCRIPTION="fmt is an open-source formatting library for C++. It can be used \
as a safe and fast alternative to (s)printf and IOStreams."
HOMEPAGE="https://github.com/fmtlib/fmt"
COPYRIGHT="2012-2020  Victor Zverovich"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://github.com/fmtlib/fmt/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="b06ca3130158c625848f3fb7418f235155a4d389b2abc3a6245fb01cb0eb1e01"
SOURCE_FILENAME="fmt-$portVersion.tar.gz"
SOURCE_DIR="fmt-$portVersion"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	libfmt$secondaryArchSuffix = $portVersion
	lib:libfmt$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libfmt${secondaryArchSuffix}_devel = $portVersion
	devel:libfmt$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libfmt$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage libfmt$secondaryArchSuffix \
	"$libDir"/libfmt.so.$portVersion

BUILD()
{
	cmake -B build -S . \
		-DBUILD_SHARED_LIBS=ON \
		-DFMT_TEST=OFF \
		$cmakeDirArgs -L
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install

	# prepare develop/lib
	prepareInstalledDevelLib libfmt
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	# enable test in BUILD()
	make -C build test
}
