SUMMARY="A Computational Geometry Algorithms Library"
DESCRIPTION="CGAL is a software project that provides easy access to efficient \
and reliable geometric algorithms in the form of a C++ library. CGAL is used \
in various areas needing geometric computation, such as geographic information \
systems, computer aided design, molecular biology, medical imaging, computer \
graphics, and robotics.

The library offers data structures and algorithms like triangulations, Voronoi \
diagrams, Boolean operations on polygons and polyhedra, point set processing, \
arrangements of curves, surface and volume mesh generation, geometry \
processing, alpha shapes, convex hull algorithms, shape analysis, AABB and KD \
trees..."
HOMEPAGE="https://www.cgal.org/"
COPYRIGHT="2005 Stanford University (USA)
	2008, 2011 GeometryFactory (France)
	1999-2004 Max-Planck-Institute Saarbruecken (Germany)
	1995-2004 Exact Computation Project
	1997-2004, 2005-2008 ASCLEPIOS Project, INRIA Sophia-Antipolis (France)
	1997-2004 Utrecht University (The Netherlands)
	1997-2004 ETH Zurich (Switzerland)
	1997-2004 Tel-Aviv University (Israel)"
LICENSE="GNU GPL v3
	GNU LGPL v3
	Boost v1.0
	MIT"
REVISION="1"
SOURCE_URI="https://github.com/CGAL/cgal/archive/releases/CGAL-$portVersion.tar.gz"
CHECKSUM_SHA256="c4912a00e99f29ee37cac1d780d115a048743370b9329a2cca839ffb392f3516"
SOURCE_DIR="cgal-releases-CGAL-$portVersion"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
 	commandSuffix=
 	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	cgal$secondaryArchSuffix = $portVersion
	cmd:cgal_create_cmakelists
	cmd:cgal_create_cmake_script
	cmd:cgal_make_macosx_app
	lib:libCGAL$secondaryArchSuffix = $libVersionCompat
	lib:libCGAL_Core$secondaryArchSuffix = $libVersionCompat
	lib:libCGAL_ImageIO$secondaryArchSuffix = $libVersionCompat
	lib:libCGAL_Qt5$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_atomic$secondaryArchSuffix
	lib:libboost_chrono$secondaryArchSuffix
	lib:libboost_date_time$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libboost_thread$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libgmp$secondaryArchSuffix
	lib:libmpfr$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5OpenGL$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	cgal${secondaryArchSuffix}_devel = $portVersion
	devel:libcgal$secondaryArchSuffix = $libVersionCompat
	devel:libCGAL_Core$secondaryArchSuffix = $libVersionCompat
	devel:libCGAL_ImageIO$secondaryArchSuffix = $libVersionCompat
	devel:libCGAL_Qt5$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	cgal$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:eigen$secondaryArchSuffix
	devel:libboost_atomic$secondaryArchSuffix
	devel:libboost_chrono$secondaryArchSuffix
	devel:libboost_date_time$secondaryArchSuffix
	devel:libboost_system$secondaryArchSuffix
	devel:libboost_thread$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libgmp$secondaryArchSuffix
	devel:libmpfr$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5OpenGL$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage cgal$secondaryArchSuffix \
	"$libDir"/libCGAL.so.$libVersion \
	"$libDir"/libCGAL_Core.so.$libVersion \
	"$libDir"/libCGAL_ImageIO.so.$libVersion \
	"$libDir"/libCGAL_Qt5.so.$libVersion

BUILD()
{
	mkdir -p build && cd build
	cmake .. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DWITH_Eigen3=ON \
		-DBUILD_TESTING=ON \
		-DCGAL_INSTALL_CMAKE_DIR="$relativeLibDir/cmake" \
		-DCGAL_INSTALL_DOC_DIR="$docDir" \
		-DCGAL_INSTALL_MAN_DIR="$manDir/man1" \
		-DCMAKE_CXX_FLAGS="-DBOOST_NO_CXX11_CONSTEXPR"

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs libCGAL libCGAL_Core libCGAL_ImageIO \
		libCGAL_Qt5
	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	cd build
	make test
}
