SUMMARY="A microbenchmark support library"
DESCRIPTION="A library to support the benchmarking of functions, similar to unit-tests."
HOMEPAGE="https://github.com/google/benchmark/"
COPYRIGHT="2015-2017 Google Benchmark developers"
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="https://github.com/google/benchmark/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4"
SOURCE_FILENAME="benchmark-$portVersion.tar.gz"

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

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

PROVIDES="
	benchmark$secondaryArchSuffix = $portVersion
	lib:libbenchmark$secondaryArchSuffix = $libVersionCompat
	lib:libbenchmark_main$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	gtest$secondaryArchSuffix
	"

PROVIDES_devel="
	benchmark${secondaryArchSuffix}_devel = $portVersion
	devel:libbenchmark$secondaryArchSuffix = $libVersionCompat
	devel:libbenchmark_main$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	benchmark$secondaryArchSuffix == $portVersion base
	"

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

defineDebugInfoPackage benchmark$secondaryArchSuffix \
	"$libDir"/libbenchmark.so.$libVersion \
	"$libDir"/libbenchmark_main.so.$libVersion

BUILD()
{
	cmake -Bbuild -S. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE='Release' \
		-DBUILD_SHARED_LIBS:BOOL=ON \
		-DBENCHMARK_ENABLE_GTEST_TESTS:BOOL=OFF
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install

	prepareInstalledDevelLibs libbenchmark libbenchmark_main
	fixPkgconfig

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

TEST()
{
	make -C build test
}
