Gentoo Archives: gentoo-commits

From: Joonas Niilola <juippis@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-libs/opensubdiv/files/, media-libs/opensubdiv/
Date: Mon, 22 Nov 2021 14:11:15
Message-Id: 1637590219.fc0a2d9cd04c458e48543abea41bba7882913e93.juippis@gentoo
1 commit: fc0a2d9cd04c458e48543abea41bba7882913e93
2 Author: Alexander Golubev <fatzer2 <AT> gmail <DOT> com>
3 AuthorDate: Sat Nov 6 23:14:33 2021 +0000
4 Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 22 14:10:19 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc0a2d9c
7
8 media-libs/opensubdiv: use cuda eclass
9
10 * Utilize cuda eclass and let it handle gcc selection instead of forcing
11 an outdated version.
12 * Add a fix to provide sane defaults when compiling against a recent
13 enough CUDA versions.
14 * Add an option to pass user-specified NVCCFLAGS and prevent cmake from
15 overriding them.
16
17 Closes: https://bugs.gentoo.org/744517
18 Closes: https://bugs.gentoo.org/751382
19 Signed-off-by: Alexander Golubev <fatzer2 <AT> gmail.com>
20 Closes: https://github.com/gentoo/gentoo/pull/22852
21 Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>
22
23 ...opensubdiv-3.4.4-add-CUDA11-compatibility.patch | 19 +++++
24 media-libs/opensubdiv/opensubdiv-3.4.4-r2.ebuild | 93 ++++++++++++++++++++++
25 2 files changed, 112 insertions(+)
26
27 diff --git a/media-libs/opensubdiv/files/opensubdiv-3.4.4-add-CUDA11-compatibility.patch b/media-libs/opensubdiv/files/opensubdiv-3.4.4-add-CUDA11-compatibility.patch
28 new file mode 100644
29 index 000000000000..8f5bfab43a92
30 --- /dev/null
31 +++ b/media-libs/opensubdiv/files/opensubdiv-3.4.4-add-CUDA11-compatibility.patch
32 @@ -0,0 +1,19 @@
33 +From: "Alexander Golubev" <fatzer2@×××××.com>
34 +
35 +Set correct default minimal -arch for CUDA 9 and 11
36 +--- OpenSubdiv-3_4_4/CMakeLists.txt 2021-11-07 02:01:07.899484952 +0300
37 ++++ OpenSubdiv-3_4_4/CMakeLists.txt.new 2021-11-07 02:01:23.402764409 +0300
38 +@@ -587,8 +587,12 @@
39 + if (NOT DEFINED OSD_CUDA_NVCC_FLAGS)
40 + if (CUDA_VERSION_MAJOR LESS 6)
41 + set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_11 )
42 +- else()
43 ++ elseif (CUDA_VERSION_MAJOR LESS 9)
44 + set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_20 )
45 ++ elseif (CUDA_VERSION_MAJOR LESS 11)
46 ++ set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_30 )
47 ++ else()
48 ++ set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_35 )
49 + endif()
50 + endif()
51 + endif()
52
53 diff --git a/media-libs/opensubdiv/opensubdiv-3.4.4-r2.ebuild b/media-libs/opensubdiv/opensubdiv-3.4.4-r2.ebuild
54 new file mode 100644
55 index 000000000000..e175e9f49681
56 --- /dev/null
57 +++ b/media-libs/opensubdiv/opensubdiv-3.4.4-r2.ebuild
58 @@ -0,0 +1,93 @@
59 +# Copyright 1999-2021 Gentoo Authors
60 +# Distributed under the terms of the GNU General Public License v2
61 +
62 +EAPI=8
63 +
64 +CMAKE_MAKEFILE_GENERATOR=emake
65 +
66 +inherit cmake cuda toolchain-funcs
67 +
68 +MY_PV="$(ver_rs "1-3" '_')"
69 +DESCRIPTION="An Open-Source subdivision surface library"
70 +HOMEPAGE="https://graphics.pixar.com/opensubdiv/docs/intro.html"
71 +SRC_URI="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz"
72 +S="${WORKDIR}/OpenSubdiv-${MY_PV}"
73 +
74 +# Modfied Apache-2.0 license, where section 6 has been replaced.
75 +# See for example CMakeLists.txt for details.
76 +LICENSE="Apache-2.0"
77 +SLOT="0"
78 +KEYWORDS="~amd64 ~arm ~arm64 ~x86"
79 +IUSE="cuda examples opencl openmp ptex tbb test tutorials"
80 +RESTRICT="!test? ( test )"
81 +
82 +RDEPEND="
83 + media-libs/glew:=
84 + media-libs/glfw:=
85 + x11-libs/libXinerama
86 + cuda? ( dev-util/nvidia-cuda-toolkit:* )
87 + opencl? ( virtual/opencl )
88 + ptex? ( media-libs/ptex )
89 +"
90 +DEPEND="
91 + ${RDEPEND}
92 + tbb? ( <dev-cpp/tbb-2021.4.0:= )
93 +"
94 +
95 +PATCHES=(
96 + "${FILESDIR}/${PN}-3.3.0-use-gnuinstalldirs.patch"
97 + "${FILESDIR}/${PN}-3.4.3-install-tutorials-into-bin.patch"
98 + "${FILESDIR}/${P}-add-CUDA11-compatibility.patch"
99 +)
100 +
101 +pkg_pretend() {
102 + [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
103 +}
104 +
105 +pkg_setup() {
106 + [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
107 +}
108 +
109 +src_prepare() {
110 + cmake_src_prepare
111 +
112 + use cuda && cuda_src_prepare
113 +}
114 +
115 +src_configure() {
116 + # GLTESTS are disabled as portage is unable to open a display during test phase
117 + # TODO: virtx work?
118 + local mycmakeargs=(
119 + -DGLEW_LOCATION="${ESYSROOT}/usr/$(get_libdir)"
120 + -DGLFW_LOCATION="${ESYSROOT}/usr/$(get_libdir)"
121 + -DNO_CLEW=ON
122 + -DNO_CUDA=$(usex !cuda)
123 + # Docs needed Python 2 so disabled
124 + # bug #815172
125 + -DNO_DOC=ON
126 + -DNO_EXAMPLES=$(usex !examples)
127 + -DNO_GLTESTS=ON
128 + -DNO_OMP=$(usex !openmp)
129 + -DNO_OPENCL=$(usex !opencl)
130 + -DNO_PTEX=$(usex !ptex)
131 + -DNO_REGRESSION=$(usex !test)
132 + -DNO_TBB=$(usex !tbb)
133 + -DNO_TESTS=$(usex !test)
134 + -DNO_TUTORIALS=$(usex !tutorials)
135 + )
136 +
137 + if use cuda; then
138 + # old cmake CUDA module doesn't use environment variable to initialize flags
139 + mycmakeargs+=( -DCUDA_NVCC_FLAGS="${NVCCFLAGS}" )
140 +
141 + # check if user provided --gpu-architecture/-arch flag and prevent cmake from overriding it if so
142 + for f in ${NVCCFLAGS}; do
143 + if [[ ${f} == -arch* || ${f} == --gpu-architecture* ]]; then
144 + mycmakeargs+=( -DOSD_CUDA_NVCC_FLAGS="" )
145 + break
146 + fi
147 + done
148 + fi
149 +
150 + cmake_src_configure
151 +}