SUMMARY="C++ test framework"
DESCRIPTION="C++ testing utility
Features:
* An xUnit test framework
* Test discovery
* A rich set of assertions
* User-defined assertions
* Death tests
* Fatal and non-fatal failures
* Value-parameterized tests
* Type-parameterized tests
* Various options for running the tests
* XML test report generation"
HOMEPAGE="https://github.com/google/googletest"
COPYRIGHT="2008-2019 Google Test developers"
LICENSE="BSD (3-clause)"
REVISION="2"
SOURCE_URI="https://github.com/google/googletest/archive/release-$portVersion.tar.gz"
CHECKSUM_SHA256="b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5"
SOURCE_FILENAME="googletest-release-$portVersion.tar.gz"
SOURCE_DIR="googletest-release-$portVersion"
PATCHES="gtest-$portVersion.patchset"

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

PROVIDES="
	gtest$secondaryArchSuffix = $portVersion
	lib:libgmock$secondaryArchSuffix
	lib:libgmock_main$secondaryArchSuffix
	lib:libgtest$secondaryArchSuffix
	lib:libgtest_main$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	gtest${secondaryArchSuffix}_devel = $portVersion
	devel:libgmock$secondaryArchSuffix
	devel:libgmock_main$secondaryArchSuffix
	devel:libgtest$secondaryArchSuffix
	devel:libgtest_main$secondaryArchSuffix
	"
REQUIRES_devel="
	gtest$secondaryArchSuffix == $portVersion base
	"

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

defineDebugInfoPackage gtest$secondaryArchSuffix \
	$libDir/libgmock.so.1.11.0 \
	$libDir/libgmock_main.so.1.11.0 \
	$libDir/libgtest.so.1.11.0 \
	$libDir/libgtest_main.so.1.11.0

BUILD()
{
	mkdir -p build && cd build

	cmake .. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE='Release' \
		-DBUILD_SHARED_LIBS:BOOL=ON \
		-Dgtest_build_tests=ON
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	echo -e "prefix=$prefix\n$(cat $libDir/pkgconfig/gtest.pc)" \
		> $libDir/pkgconfig/gtest.pc
	echo -e "prefix=$prefix\n$(cat $libDir/pkgconfig/gtest_main.pc)" \
		> $libDir/pkgconfig/gtest_main.pc
	echo -e "prefix=$prefix\n$(cat $libDir/pkgconfig/gmock.pc)" \
		> $libDir/pkgconfig/gmock.pc
	echo -e "prefix=$prefix\n$(cat $libDir/pkgconfig/gmock_main.pc)" \
		> $libDir/pkgconfig/gmock_main.pc
	prepareInstalledDevelLibs libgmock libgmock_main libgtest libgtest_main
	fixPkgconfig

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

TEST()
{
	make -C build test
}
