*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / sci-libs / med / med-4.0.0-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 # EAPI=7 uses ninja generator by default but it's incompatible with USE=fortran
7 # https://github.com/Kitware/ninja/tree/features-for-fortran#readme
8 CMAKE_MAKEFILE_GENERATOR=emake
9
10 FORTRAN_NEEDED=fortran
11
12 # NOTE:The build for multiple python versions should be possible but
13 # complicated for the build system
14 PYTHON_COMPAT=( python3_{6,7} )
15
16 inherit cmake fortran-2 python-single-r1
17
18 DESCRIPTION="A library to store and exchange meshed data or computation results"
19 HOMEPAGE="https://www.salome-platform.org/user-section/about/med"
20 SRC_URI="https://files.salome-platform.org/Salome/other/${P}.tar.gz"
21
22 LICENSE="LGPL-3"
23 SLOT="0"
24 KEYWORDS="~amd64 ~x86"
25 IUSE="doc fortran mpi python test"
26
27 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
28
29 RESTRICT="!test? ( test ) python? ( test )"
30
31 # dev-lang/tk is needed for wish-based xmdump utility
32 RDEPEND="
33         !sci-libs/libmed
34         dev-lang/tk:0=
35         >=sci-libs/hdf5-1.10.2:=[fortran?,mpi?]
36         mpi? ( virtual/mpi[fortran=] )
37         python? ( ${PYTHON_DEPS} )
38 "
39 DEPEND="${RDEPEND}"
40 BDEPEND="python? ( >=dev-lang/swig-3.0.8 )"
41
42 PATCHES=(
43         "${FILESDIR}/${PN}-3.3.1-cmake-fortran.patch"
44         "${FILESDIR}/${PN}-3.3.1-disable-python-compile.patch"  # managed by function of python eclass
45         "${FILESDIR}/${P}-cmakelist.patch"
46         "${FILESDIR}/${P}-installdoc.patch"
47 )
48
49 DOCS=( AUTHORS ChangeLog NEWS README TODO )
50
51 pkg_setup() {
52         use python && python-single-r1_pkg_setup
53         use fortran && fortran-2_pkg_setup
54 }
55
56 src_prepare() {
57         if use python; then
58                 # fixes for correct libdir name
59                 local pysite=$(python_get_sitedir)
60                 pysite="${pysite##/usr/}"
61                 sed \
62                         -e 's@SET(_install_dir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/med)@SET(_install_dir '${pysite}'/med)@' \
63                         -i ./python/CMakeLists.txt || die "sed on ./python/CMakeLists.txt failed"
64         fi
65         for cm in ./src/CMakeLists.txt ./tools/medimport/CMakeLists.txt
66         do
67                 sed -i -e "s@INSTALL(TARGETS \(.*\) DESTINATION lib)@INSTALL(TARGETS \1 DESTINATION $(get_libdir))@" \
68                         "${cm}" || die "sed on ${cm} failed"
69         done
70
71         cmake_src_prepare
72 }
73
74 src_configure() {
75         local mycmakeargs=(
76                 # as indicated in the CMakeLists.txt, the shipped documentation is generated by a custom doxygen,
77                 # so let's avoid rebuilding it because it will be different
78                 -DMEDFILE_BUILD_DOC=OFF
79                 -DMEDFILE_BUILD_FORTRAN=$(usex fortran)
80                 -DMEDFILE_BUILD_PYTHON=$(usex python)
81                 -DMEDFILE_BUILD_SHARED_LIBS=ON
82                 -DMEDFILE_BUILD_STATIC_LIBS=OFF
83                 -DMEDFILE_BUILD_TESTS=$(usex test)
84                 -DMEDFILE_DOC_DIRECTORY="${EPREFIX}"/usr/share/doc/${PF}/html   # custom var created by patches
85                 -DMEDFILE_INSTALL_DOC=$(usex doc)
86                 -DMEDFILE_USE_MPI=$(usex mpi)
87         )
88         cmake_src_configure
89 }
90
91 src_install() {
92         cmake_src_install
93
94         # we don't need old 2.3.6 include files
95         rm -r "${ED}"/usr/include/2.3.6 || die "failed to delete obsolete include dir"
96
97         # the optimization done in CMakeLists.txt has been disabled so
98         # we need to do it manually
99         use python && python_optimize
100
101         # Prevent test executables being installed
102         if use test; then
103                 rm -r "${ED}"/usr/bin/testc || die "failed to delete C test executables"
104                 if use fortran; then
105                         rm -r "${ED}"/usr/bin/testf || die "failed to delete fortran test executables"
106                 fi
107                 if use python; then
108                         rm -r "${ED}"/usr/bin/testpy || die "failed to delete python test executables"
109                 fi
110         fi
111 }
112
113 src_test() {
114         # override parallel mode only for tests
115         local myctestargs=( "-j 1" )
116         cmake_src_test
117 }