From 1efcaea64a1cb616f5370e5e462ae7c6090d5c21 Mon Sep 17 00:00:00 2001 From: AngePierre Date: Thu, 10 Sep 2026 17:28:10 +0200 Subject: [PATCH] wrapper: give cmake CUDA explicitly (needed to configure) by SoC arch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wrapper enables the CUDA language, so it will not configure without a working CUDA — even though libk4arecord_v2.so does not use it. A non-interactive shell has no cuda/bin on PATH, so point cmake at nvcc and pass the architecture derived from the SoC (Orin = sm_87). Co-Authored-By: Claude Opus 5 (1M context) --- scripts/build_k4a_wrapper.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/build_k4a_wrapper.sh b/scripts/build_k4a_wrapper.sh index a551574..26fe61d 100755 --- a/scripts/build_k4a_wrapper.sh +++ b/scripts/build_k4a_wrapper.sh @@ -22,6 +22,29 @@ eval "$("$here/detect_platform.sh")" REPO_URL="${OB_K4A_REPO:-https://github.com/orbbec/OrbbecSDK-K4A-Wrapper}" REF="${OB_K4A_REF:-v1.10.4}" +# The wrapper enables the CUDA language (its bundled OrbbecSDK does), so it will +# not even CONFIGURE without a working CUDA — regardless of libk4arecord_v2.so not +# using it. A non-interactive shell has no cuda/bin on PATH, so point cmake at it +# and give the architecture by SoC (cmake needs it explicit here). Empty when no +# CUDA is found, letting cmake try its own detection. +cuda_flags() { + local nvcc + for nvcc in /usr/local/cuda/bin/nvcc /usr/local/cuda-*/bin/nvcc; do + [[ -x "$nvcc" ]] && break + done + [[ -x "$nvcc" ]] || return 0 + local arch + case "$SOC" in + tegra210) arch=53 ;; # Nano, TX1 + tegra186) arch=62 ;; # TX2 + tegra194) arch=72 ;; # Xavier + tegra234) arch=87 ;; # Orin + tegra264) arch=101 ;; # Thor + *) arch=87 ;; # a reasonable modern default + esac + printf -- '-DCMAKE_CUDA_COMPILER=%s -DCMAKE_CUDA_ARCHITECTURES=%s' "$nvcc" "$arch" +} + # A usable wrapper base: headers and the stock libk4a. The v2 target is ensured # separately, so a wrapper built before this repo existed still qualifies. find_wrapper() { @@ -49,7 +72,7 @@ ensure_recordv2() { fi ( cd "$d/build" - cmake .. -DCMAKE_BUILD_TYPE=Release >&2 + cmake .. -DCMAKE_BUILD_TYPE=Release $(cuda_flags) >&2 make -j"$(nproc)" k4arecord_v2 >&2 ) [[ -f "$d/build/lib/libk4arecord_v2.so" ]] @@ -82,7 +105,7 @@ fi mkdir -p "$dir/build" ( cd "$dir/build" - cmake .. -DCMAKE_BUILD_TYPE=Release >&2 + cmake .. -DCMAKE_BUILD_TYPE=Release $(cuda_flags) >&2 make -j"$(nproc)" k4a k4arecord >&2 ) if ! find_wrapper "$dir" >/dev/null 2>&1 || ! ensure_recordv2 "$dir"; then