summaryrefslogtreecommitdiff
blob: f08ec70da1b48d3fd09d7b4d9e23717b8c1b7c00 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake cuda toolchain-funcs

DESCRIPTION="Fast approximate nearest neighbor searches in high dimensional spaces"
HOMEPAGE="https://github.com/flann-lib/flann"
SRC_URI="https://github.com/flann-lib/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~x86 ~amd64-linux ~x86-linux"
IUSE="cuda doc examples mpi octave openmp"

BDEPEND="
	app-arch/unzip
	doc? ( dev-tex/latex2html )
	mpi? ( app-admin/chrpath )
"
DEPEND="
	app-arch/lz4:=
	cuda? ( >=dev-util/nvidia-cuda-toolkit-5.5 )
	mpi? (
		dev-libs/boost:=[mpi]
		sci-libs/hdf5:=[mpi=]
	)
	octave? ( >=sci-mathematics/octave-3.6.4-r1:= )
"
RDEPEND="${DEPEND}"
# TODO:
# readd dependencies for test suite,
# requires multiple ruby dependencies

PATCHES=(
	"${FILESDIR}"/${PN}-1.9.1-build-oct-rather-than-mex-files-for-octave.patch # bug 830424
	"${FILESDIR}"/${PN}-1.9.2-asio-boost187.patch
	"${FILESDIR}"/${PN}-1.9.2-boost-config.patch
)

pkg_pretend() {
	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
}

pkg_setup() {
	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
}

src_prepare() {
	# bug #302621
	use mpi && export CXX=mpicxx

	use cuda && cuda_src_prepare

	cmake_src_prepare
}

src_configure() {
	# python bindings are split off into dev-python/pyflann
	local mycmakeargs=(
		-DCMAKE_CXX_STANDARD=17
		-DBUILD_C_BINDINGS=ON
		-DBUILD_PYTHON_BINDINGS=OFF
		-DBUILD_CUDA_LIB="$(usex cuda)"
		-DBUILD_EXAMPLES="$(usex examples)"
		-DBUILD_DOC="$(usex doc)"
		-DBUILD_TESTS=OFF
		-DBUILD_MATLAB_BINDINGS="$(usex octave)"
		-DUSE_MPI="$(usex mpi)"
		-DUSE_OPENMP="$(usex openmp)"
	)

	# einfo "NVCCFLAGS ${NVCCFLAGS}"
	use cuda && mycmakeargs+=(
		# -DCUDA_NVCC_FLAGS="${NVCCFLAGS} --linker-options \"-arsch\""
		-DCUDA_NVCC_FLAGS="--compiler-bindir;$(cuda_gccdir)"
	)
	use doc && mycmakeargs+=( -DDOCDIR="share/doc/${PF}" )

	cmake_src_configure
}

src_install() {
	cmake_src_install
	find "${ED}" -name 'lib*.a' -delete || die

	# bug 795828; mpicc voluntarily adds some runpaths
	if use mpi; then
		chrpath -d "${ED}/usr/bin/flann_mpi_"{client,server} || die
	fi
}