# Template file for 'cegui'
pkgname=cegui
version=0.8.7.20190225
revision=6
_githash=bfc6a841de45b8e63040d33b9cccc67745337f4e
build_style=cmake
configure_args="-DOpenGL_GL_PREFERENCE=GLVND \
 -DCEGUI_BUILD_RENDERER_OPENGL=ON \
 -DCEGUI_SAMPLES_ENABLED=OFF"
make_build_args="all html"
hostmakedepends="graphviz doxygen dejavu-fonts-ttf gd glm perl pkg-config"
makedepends="libglvnd-devel SDL2-devel SDL2_image-devel libxml2-devel
 boost-devel devil-devel glfw-devel glm ois-devel silly-devel fribidi-devel
 lua53-devel minizip-devel freetype-devel
 $(vopt_if irrlicht irrlicht-devel)
 $(vopt_if ogre libogre-devel)"
short_desc="Crazy Eddie's Graphical User Interface"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="http://cegui.org.uk/"
distfiles="https://github.com/cegui/cegui/archive/${_githash}.tar.gz"
checksum=70156257313b81d068d6592887157dd16b91d7bc0dfdcba02a96ed371d329e64
replaces="cegui-data>=0 cegui-sample>=0"

build_options="irrlicht ogre"
desc_option_irrlicht="Enable support for Irrlicht"
desc_option_ogre="Enable support for Ogre"

if [ -z "$CROSS_BUILD" ]; then
	# irrlicht interface fails to cross compile
	build_options_default+=" irrlicht"
fi

# Silence log output
CXXFLAGS="-Wno-unused-parameter -Wno-deprecated-copy"

pre_configure() {
	# Use a FindOpenGLES.cmake which works
	cp -p ${FILESDIR}/FindOpenGLES.cmake cmake

	# cmake sets standard to c++03 (which doesn’t know int16_t)
	vsed -i -e "s/-std=c++03//" CMakeLists.txt
}
post_install() {
	local _ver2=${version%.*.*}
	vlicense COPYING
	ln -srv ${DESTDIR}/usr/lib/{cegui-${_ver2},}/libCEGUICoreWindowRendererSet.so
	ln -srv ${DESTDIR}/usr/lib/{cegui-${_ver2},}/libCEGUISILLYImageCodec.so
	ln -srv ${DESTDIR}/usr/lib/{cegui-${_ver2},}/libCEGUIDevILImageCodec.so
	ln -srv ${DESTDIR}/usr/lib/{cegui-${_ver2},}/libCEGUIExpatParser.so
	ln -srv ${DESTDIR}/usr/lib/{cegui-${_ver2},}/libCEGUILibXMLParser.so
}
cegui-doc_package() {
	short_desc+=" - documentation"
	pkg_install() {
		vmkdir usr/share/doc/${sourcepkg}
		vcopy ${wrksrc}/build/doc/doxygen/html usr/share/doc/${sourcepkg}
	}
}
cegui-devel_package() {
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/libCEGUI*-0.so"
	}
}
