SUMMARY="A 3D model slicing engine for 3D printing"
DESCRIPTION="The CuraEngine is a C++ console application for 3D printing GCode generation. \
It has been made as a better and faster alternative to the old Skeinforge engine."
HOMEPAGE="https://github.com/Ultimaker/CuraEngine"
COPYRIGHT="2011-2020 Ultimaker BV"
LICENSE="AGPL-3.0"
REVISION="1"
SOURCE_URI="https://github.com/Ultimaker/CuraEngine/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="752977fbe48653743b9f1a6e25e6d1f061513b7cf1cd4f0105b233595e8a15ff"
SOURCE_DIR="CuraEngine-$portVersion"
PATCHES="curaengine-$portVersion.patchset"

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

PROVIDES="
	curaengine$secondaryArchSuffix = $portVersion
	cmd:CuraEngine = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libpolyclipping$secondaryArchSuffix
	lib:libprotobuf$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libpolyclipping$secondaryArchSuffix
	devel:libprotobuf$secondaryArchSuffix
	devel:librapidjson$secondaryArchSuffix
	devel:libstdc++$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:git
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	mkdir -p build
	cd build

	cmake ..\
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX:PATH=$prefix \
		-DPolyclipping_INCLUDE_DIRS=/system/$relativeIncludeDir/polyclipping \
		-DENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS=OFF \
		-DBUILD_TESTS=OFF \
		-DENABLE_ARCUS=OFF \
		-DENABLE_OPENMP=OFF \
		-DUSE_SYSTEM_LIBS=ON

	make $jobArgs
}

INSTALL()
{
	mkdir -p $prefix/bin
	cp build/CuraEngine $prefix/bin
}
