summaryrefslogtreecommitdiff
path: root/sci-mathematics/cgal/cgal-6.1.1.ebuild
blob: 8e78d90d04a0c7c905417adbe98fd1724bc16a6b (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# Modules provided by dev-cpp/eigen
CMAKE_REMOVE_MODULES_LIST=( FindEigen3 )
inherit cmake cuda flag-o-matic multiprocessing

DESCRIPTION="C++ library for geometric algorithms and data structures"
HOMEPAGE="https://www.cgal.org/"

if [[ ${PV} == *9999* ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/${PN^^}/${PN}.git"
else
	SRC_URI="
		https://github.com/CGAL/cgal/releases/download/v${PV}/${P^^}.tar.xz
		doc? (
			https://github.com/CGAL/cgal/releases/download/v${PV}/${P^^}-doc_html.tar.xz
		)
	"
	S="${WORKDIR}/${P^^}"
	KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
fi

LICENSE="LGPL-3 GPL-3 Boost-1.0"
SLOT="0/14"

IUSE="doc test test-full"
RESTRICT="!test? ( test )"

# Referenced in the cmake files.
RDEPEND="
	dev-cpp/eigen:=
	dev-libs/boost:=
	dev-libs/gmp:=[cxx]
	dev-libs/mpfr:=
	virtual/zlib:=
"
DEPEND="${RDEPEND}
	test? (
		net-libs/libssh[server]
	)
"
BDEPEND="
	virtual/pkgconfig
"

src_prepare() {
	if use doc; then
		rm -r "doc_html" || die
		mv "${WORKDIR}/doc_html" "${S}/" || die
	fi

	cmake_src_prepare
}

src_configure() {
	# Header only since 5.0

	local mycmakeargs=(
		-DCMAKE_POLICY_DEFAULT_CMP0167="NEW"

		-DCGAL_INSTALL_LIB_DIR="$(get_libdir)"
		-DCGAL_INSTALL_CMAKE_DIR="$(get_libdir)/cmake/CGAL"

		# https://github.com/CGAL/cgal/wiki/Testing#using-ctest
		-DCGAL_ENABLE_TESTING="$(usex test)"

		# Forcibly wipe to get rid of NDEBUG. see below
		-DCMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE^^}=""
	)

	if use test; then
		# include/CGAL/config.h:53:4: error: #error The test-suite needs no NDEBUG defined
		filter-flags -DNDEBUG*

		# cmake/modules/display-third-party-libs-versions.cmake
		# these need use flags eventually
		local deps=(
			VTK
		)
		deps+=(
			# Ceres
			# GLPK
			# # GMP
			# ITK
			# ITT
			# LASLIB
			# libpointmatcher
			# METIS
			# MPFI
			# # MPFR
			# OpenCV
			# OpenGR
			# OSQP
			# SCIP
			# SuiteSparse
			# TBB
			# # VTK
			# # ZLIB
			# # LEDA # unused
			# # MKL
			# # RS
			# # RS3
			# SCIP
			# # UMFPACK
			# Eigen3
			Qt6
			# # ESBTL # unused
			# # IPE # unused
			# # LibSSH # unused
			OpenMesh
		)

		if use test-full; then
			# Optionally depends on sci-lib/vtk, which looks up a cuda compiler iff build with USE=cuda.
			# We therefore need to set the correct CUDAHOSTCXX and setup the sandbox.
			if has_version "sci-libs/vtk[cuda]" ; then
				cuda_add_sandbox
				addpredict "/dev/char/"
				local -x CUDAHOSTCXX="$(cuda_gccdir)"
			fi
		else
			deps+=(
				# Threads
				# Boost
			)
		fi

		mycmakeargs+=(
			-DCGAL_CTEST_DISPLAY_MEM_AND_TIME="yes"
			# exits some tests early
			-DCGAL_TEST_SUITE="yes"
			-DCGAL_TEST_DRAW_FUNCTIONS="yes"
			-DCGAL_DISABLE_GMP="no"
			# -DCGAL_WITH_benchmark="$(usex test "$(usex benchmark)")" # wired up but not present
			-DCGAL_WITH_demos="$(usex test "$(usex test-full)")"
			-DCGAL_WITH_examples="$(usex test "$(usex test-full)")"
		)

		if [[ -n "${deps[@]}" ]]; then
			mycmakeargs+=(
				# 964750
				# this does not work as demos and examples are separate cmake calls that ignore mycmakeargs
				$(printf -- "-DCMAKE_DISABLE_FIND_PACKAGE_%s=yes " "${deps[@]}")
			)
		fi
	fi

	cmake_src_configure
}

src_compile() {
	if use test; then
		local targets=(
			ALL_CGAL_TARGETS
		)
		if use test-full; then
			targets+=(
				demos
				examples
			)
		fi

		cmake_src_compile "${targets[@]}"
	fi
}

src_test() {
	# tests have split compilation & execution stages that do not depend on each other, but break when run out of order
	# We pass CMAKE_BUILD_PARALLEL_LEVEL to run compilation tests in parallel
	local -x CMAKE_BUILD_PARALLEL_LEVEL="$(get_makeopts_jobs)"
	einfo "using CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL}"

	# We pass CTEST_PARALLEL_LEVEL to run execution tests in parallel
	local -x CTEST_PARALLEL_LEVEL="$(get_makeopts_jobs)"
	einfo "using CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL}"

	local -x QT_QPA_PLATFORM="offscreen"

	local CMAKE_SKIP_TESTS=(
		region_growing_planes_on_point_set_3
		mesh_3D_image_with_image_initialization
	)

	cmake_src_test -j1
}

src_install() {
	if use doc; then
		local HTML_DOCS=(
			"doc_html/."
		)
	fi

	cmake_src_install

	# if use demos; then
	# 	dodoc -r demo
	# fi

	# if use examples; then
	# 	dodoc -r examples
	# fi
}