commit:     fc6dc8aa07f880e1b962da200ff6c53204f94675
Author:     Paul Zander <negril.nx+gentoo <AT> gmail <DOT> com>
AuthorDate: Wed May 14 16:20:00 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 16 11:27:18 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc6dc8aa

media-libs/opencv: pass CMAKE_CUDA_ARCHITECTURES for FindOpenMP

cmake-3.31.0 extended FindOpenMP.cmake to look up CUDA flags
and detect compute capabilites if the CUDA language support
is enabled. This requires write access to /dev/nvidiactl.
Iff the portage user is not in the video group this will fail.
To avoid this we set the lowest supported architecture by CUDA-11.8 and
12.x, sm_50. This can be overridden by setting CUDAARCHS.

Closes: https://bugs.gentoo.org/955860
Signed-off-by: Paul Zander <negril.nx+gentoo <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42091
Signed-off-by: Sam James <sam <AT> gentoo.org>

 media-libs/opencv/opencv-4.11.0.ebuild | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/media-libs/opencv/opencv-4.11.0.ebuild 
b/media-libs/opencv/opencv-4.11.0.ebuild
index e28d08a36b61..237485b74dc8 100644
--- a/media-libs/opencv/opencv-4.11.0.ebuild
+++ b/media-libs/opencv/opencv-4.11.0.ebuild
@@ -929,22 +929,27 @@ multilib_src_configure() {
        tc-export CC CXX
 
        if multilib_native_use cuda; then
-               cuda_add_sandbox -w
-               addwrite "/proc/self/task"
-               addpredict "/dev/char/"
-
-               if ! test -w /dev/nvidiactl; then
+               if ! SANDBOX_WRITE=/dev/nvidiactl test -w /dev/nvidiactl; then
                        # eqawarn "Can't access the GPU at /dev/nvidiactl."
                        # eqawarn "User $(id -nu) is not in the group 
\"video\"."
                        if [[ -z "${CUDA_GENERATION}" ]] && [[ -z 
"${CUDA_ARCH_BIN}" ]]; then
                                # build all targets
                                mycmakeargs+=(
                                        -DCUDA_GENERATION=""
+                                       
-DCMAKE_CUDA_ARCHITECTURES="${CUDAARCHS:-50}" # breaks with openmp otherwise..
                                )
                        fi
                else
+                       cuda_add_sandbox -w
+                       addwrite "/proc/self/task"
+                       addpredict "/dev/char/"
+
                        : "${CUDAARCHS:="$(cuda_get_host_native_arch)"}"
                        export CUDAARCHS
+                       mycmakeargs+=(
+                               -DCUDA_GENERATION="${CUDAARCHS}"
+                               -DCMAKE_CUDA_ARCHITECTURES="${CUDAARCHS}"
+                       )
                fi
 
                local -x CUDAHOSTCXX CUDAHOSTLD

Reply via email to