*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / sci-libs / ceres-solver / ceres-solver-1.11.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 )
7
8 inherit cmake-multilib eutils python-any-r1 toolchain-funcs
9
10 DESCRIPTION="Nonlinear least-squares minimizer"
11 HOMEPAGE="http://ceres-solver.org/"
12 SRC_URI="${HOMEPAGE}/${P}.tar.gz"
13
14 LICENSE="sparse? ( BSD ) !sparse? ( LGPL-2.1 ) cxsparse? ( BSD )"
15 SLOT="0/1"
16 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
17 IUSE="cxsparse c++11 doc examples gflags lapack openmp +schur sparse test"
18 RESTRICT="!test? ( test )"
19
20 REQUIRED_USE="test? ( gflags ) sparse? ( lapack ) abi_x86_32? ( !sparse !lapack )"
21
22 RDEPEND="
23         dev-cpp/glog[gflags?,${MULTILIB_USEDEP}]
24         cxsparse? ( sci-libs/cxsparse:0= )
25         lapack? ( virtual/lapack )
26         sparse? (
27                 sci-libs/amd:0=
28                 sci-libs/camd:0=
29                 sci-libs/ccolamd:0=
30                 sci-libs/cholmod:0=
31                 sci-libs/colamd:0=
32                 sci-libs/spqr:0=
33         )"
34
35 DEPEND="${RDEPEND}
36         dev-cpp/eigen:3
37         doc? ( dev-python/sphinx dev-python/sphinx_rtd_theme )
38         lapack? ( virtual/pkgconfig )
39         ${PYTHON_DEPS}"
40
41 pkg_pretend() {
42         if [[ ${MERGE_TYPE} != binary ]] && use openmp; then
43                 if [[ $(tc-getCXX) == *g++* ]] && ! tc-has-openmp; then
44                         ewarn "OpenMP is not available in your current selected gcc"
45                         die "need openmp capable gcc"
46                 fi
47         fi
48 }
49
50 pkg_setup() {
51         use doc && python-any-r1_pkg_setup
52 }
53
54 src_prepare() {
55         # search paths work for prefix
56         sed -e "s:/usr:${EPREFIX}/usr:g" \
57                 -i cmake/*.cmake || die
58
59         # remove Werror
60         sed -e 's/-Werror=(all|extra)//g' \
61                 -i CMakeLists.txt || die
62
63         # respect gentoo doc install directory
64         sed -e "s:share/doc/ceres:share/doc/${PF}:" \
65                 -i docs/source/CMakeLists.txt || die
66         cmake-utils_src_prepare
67 }
68
69 src_configure() {
70         # CUSTOM_BLAS=OFF EIGENSPARSE=OFF MINIGLOG=OFF CXX11=OFF
71         local mycmakeargs=(
72                 -DBUILD_SHARED_LIBS=ON
73                 -DBUILD_EXAMPLES=OFF
74                 -DENABLE_TESTING="$(usex test)"
75                 -DCXX11="$(usex c++11)"
76                 -DBUILD_DOCUMENTATION="$(usex doc)"
77                 -DGFLAGS="$(usex gflags)"
78                 -DLAPACK="$(usex lapack)"
79                 -DOPENMP="$(usex openmp)"
80                 -DSCHUR_SPECIALIZATIONS="$(usex schur)"
81                 -DCXSPARSE="$(usex cxsparse)"
82                 -DSUITESPARSE="$(usex sparse)"
83         )
84         use sparse || use cxsparse || mycmakeargs+=( -DEIGENSPARSE=ON )
85         cmake-multilib_src_configure
86 }
87
88 src_install() {
89         cmake-multilib_src_install
90         dodoc README.md VERSION
91
92         if use examples; then
93                 insinto /usr/share/doc/${PF}
94                 docompress -x /usr/share/doc/${PF}/examples
95                 doins -r examples data
96         fi
97 }