SUMMARY="A three-dimensional finite element mesh generator"
DESCRIPTION="Gmsh is an open source 3D finite element mesh generator with a \
built-in CAD engine and post-processor. Its design goal is to provide a fast, \
light and user-friendly meshing tool with parametric input and advanced \
visualization capabilities. Gmsh is built around four modules: geometry, \
mesh, solver and post-processing. The specification of any input to these \
modules is done either interactively using the graphical user interface, in \
ASCII text files using Gmsh's own scripting language (.geo files), or using \
the C++, C, Python or Julia Application Programming Interface (API)."
HOMEPAGE="http://gmsh.info/"
COPYRIGHT="1997-2021 C. Geuzaine and J.-F. Remacle"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="http://gmsh.info/src/gmsh-4.8.4-source.tgz"
CHECKSUM_SHA256="760dbdc072eaa3c82d066c5ba3b06eacdd3304eb2a97373fe4ada9509f0b6ace"
SOURCE_DIR="gmsh-$portVersion-source"

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

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

PROVIDES="
	gmsh$secondaryArchSuffix = $portVersion
	cmd:gmsh$secondaryArchSuffix = $portVersion
	cmd:onelab.py$secondaryArchSuffix = $portVersion
	lib:libgmsh$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgmp$secondaryArchSuffix
	lib:libhdf5$secondaryArchSuffix
	"

PROVIDES_devel="
	gmsh${secondaryArchSuffix}_devel = $portVersion
	devel:libgmsh$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	gmsh$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreetype$secondaryArchSuffix
	devel:libgmp$secondaryArchSuffix
	devel:libhdf5$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3.7
	cmd:sed
	cmd:strip$secondaryArchSuffix
	"

defineDebugInfoPackage gmsh$secondaryArchSuffix \
	"$libDir"/libgmsh.so.$libVersion

BUILD()
{
	rm -rf build
	cmake -B build -S . \
		$cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DENABLE_BUILD_SHARED=ON \
		-DENABLE_BUILD_DYNAMIC=ON \
		-DCMAKE_EXE_LINKER_FLAGS="-lnetwork"

	cmake --build build $jobArgs
}

INSTALL()
{
	cmake --install build

	prepareInstalledDevelLib libgmsh

	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	cd build
	make test
}
