# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=7
inherit cmake-utils

DESCRIPTION="An C implementation of an excel writer"
HOMEPAGE="https://github.com/jmcnamara/libxlsxwriter"
SRC_URI="https://github.com/jmcnamara/${PN}/archive/RELEASE_${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD-2" # FreeBSD
SLOT="0"
KEYWORDS="~amd64 ~x86"

RDEPEND="sys-libs/zlib"
DEPEND="${RDEPEND}"

IUSE="minizip static-libs"

DEPEND="sys-libs/zlib
        minizip? ( sys-libs/zlib[minizip] )"
RDEPEND="${DEPEND}"

# required fo non-US locales. TODO: make it configurable by use flag
PATCHES=(
	"${FILESDIR}/libxlsxwriter-0.8.7-double-function.patch"
)

S="${WORKDIR}/${PN}-RELEASE_${PV}"

src_configure() {
	local mycmakeargs=(
		-DCMAKE_BUILD_TYPE=Release
		-DBUILD_SHARED_LIBS="$(usex static-libs OFF ON)"
		-DUSE_SYSTEM_MINIZIP="$(usex minizip)"
		-DUSE_DOUBLE_FUNCTION=ON
	)

	cmake-utils_src_configure
}

src_install() {
	cmake-utils_src_install
	dodoc CONTRIBUTING.md License.txt Readme.md Changes.txt
	dodoc -r docs examples
	
	find "${D}" -name '*.la' -delete
}