summaryrefslogtreecommitdiff
blob: 1fcf5fe358b0d6072ce8dfb5f67a469c0c903dfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

CMAKE_MAKEFILE_GENERATOR="emake" # needed for tests
inherit cmake

DESCRIPTION="COIN-OR C++ Algorithmic Differentiation"
HOMEPAGE="https://projects.coin-or.org/CppAD/"
SRC_URI="https://github.com/coin-or/CppAD/archive/${PV}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}/CppAD-${PV}"

LICENSE="EPL-2.0"
SLOT="0/${PV}" # soname is bumped every versions
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
IUSE="adolc doc eigen ipopt"

# adolc currently can't build tests and ipopt fails them.
RESTRICT="adolc? ( test ) ipopt? ( test )"

# No need for RDEPEND.
DEPEND="
	dev-libs/boost[threads(+)]
	adolc? ( sci-libs/adolc )
	eigen? ( dev-cpp/eigen )
	ipopt? ( sci-libs/ipopt )"
BDEPEND="
	virtual/pkgconfig
	doc? (
		app-doc/doxygen[dot]
		virtual/latex-base
	)"

PATCHES=( "${FILESDIR}"/${P}-pkgconfig.patch )

src_prepare() {
	cmake_src_prepare
	# Gentoo uses coin/ rather than coin-or/ for includes.
	sed -i 's/<coin-or/<coin/' \
		cppad_ipopt/src/cppad_ipopt_nlp.hpp \
		include/cppad/ipopt/solve_callback.hpp || die
}

src_configure() {
	local mycmakeargs=(
		-Dcmake_install_libdirs=$(get_libdir)
		-Dinclude_adolc=$(usex adolc)
		-Dinclude_cppadcg=no
		-Dinclude_eigen=$(usex eigen)
		-Dinclude_ipopt=$(usex ipopt)
	)
	cmake_src_configure
}

src_compile() {
	cmake_src_compile
	if use doc; then
		bin/doxyfile.sh ${PV} dox.log doc && doxygen doxyfile || die
	fi
}

src_test() {
	cmake_build check
}

src_install() {
	cmake_src_install
	use doc && dodoc -r doc/html

	# Remove superfluous .pc file.
	rm -r "${ED}"/usr/share/pkgconfig || die
}