SUMMARY="Importer library to import assets from 3D files"
DESCRIPTION="Open Asset Import Library (short name: Assimp) is a portable \
Open Source library to import various well-known 3D model formats in a \
uniform manner. The most recent version also knows how to export 3d files \
and is therefore suitable as a general-purpose 3D model converter."
HOMEPAGE="https://assimp.org"
COPYRIGHT="2006-2020, assimp team"
LICENSE="BSD (3-clause)"
REVISION="2"
SOURCE_URI="https://github.com/assimp/assimp/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="11310ec1f2ad2cd46b95ba88faca8f7aaa1efe9aa12605c55e3de2b977b3dbfc"
PATCHES="assimp-$portVersion.patchset"

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

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

PROVIDES="
	assimp$secondaryArchSuffix = $portVersion
	cmd:assimp$secondaryArchSuffix = $portVersion
	lib:libassimp$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libgtest$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libminizip$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	assimp${secondaryArchSuffix}_devel = $portVersion
	devel:libassimp$secondaryArchSuffix = $libVersionCompat
	devel:libirrxml$secondaryArchSuffix = $libVersion
	"
REQUIRES_devel="
	assimp$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libgomp$secondaryArchSuffix
	devel:libminizip$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:doxygen
	cmd:ninja
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage assimp$secondaryArchSuffix \
	"$libDir"/libassimp.so.$libVersion

BUILD()
{
	cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release \
		-DASSIMP_BIN_INSTALL_DIR=$binDir \
		-DASSIMP_LIB_INSTALL_DIR=$libDir \
		-DASSIMP_INCLUDE_INSTALL_DIR=$includeDir \
		-DBUILD_SHARED_LIBS=ON \
		-DASSIMP_BUILD_TESTS=ON \
		-DASSIMP_BUILD_ASSIMP_TOOLS=ON \
		-DBUILD_DOCS=ON \
		-DCMAKE_INSTALL_DOCDIR=$developDocDir \
		.
	ninja -j1 -C build
}

INSTALL()
{
	ninja -C build install

	prepareInstalledDevelLibs libassimp libIrrXML

	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	export LIBRARY_PATH="$LIBRARY_PATH:$sourceDir/build/code"
	build/test/unit
}
