wrapper: give cmake CUDA explicitly (needed to configure) by SoC arch

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) <noreply@anthropic.com>
This commit is contained in:
AngePierreandClaude Opus 5 committed 2026-09-10 17:28:10 +02:00
1 parent cabca69c4d
commit 1efcaea64a
1 file changed
+25 -2
+25 -2
View File
@@ -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