From d391009ce59c1e55e72568adc1a4581f04b0c11b Mon Sep 17 00:00:00 2001 From: Changjie Date: Sat, 20 Aug 2022 15:59:04 +0200 Subject: [PATCH 1/2] Update CMakeLists.txt Update CUDA_INCLUDE_DIRECTORIES to support external cuda samples directory. --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8ef04736..2a182a498 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,12 +347,15 @@ IF(ENABLE_CUDA) SET(LIBFREENECT2_WITH_CUDA_SUPPORT 1) SET(HAVE_CUDA yes) - STRING(REPLACE "\\" "/" NVCUDASAMPLES_ROOT "$ENV{NVCUDASAMPLES_ROOT}") + IF(NOT DEFINED NVCUDASAMPLES_ROOT) + STRING(REPLACE "\\" "/" NVCUDASAMPLES_ROOT "$ENV{NVCUDASAMPLES_ROOT}") + ENDIF() STRING(REPLACE "\\" "/" NVCUDASAMPLES8_0_ROOT "$ENV{NVCUDASAMPLES8_0_ROOT}") CUDA_INCLUDE_DIRECTORIES( "${MY_DIR}/include/" "${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc" "${NVCUDASAMPLES_ROOT}/common/inc" + "${NVCUDASAMPLES_ROOT}/Common" "${NVCUDASAMPLES8_0_ROOT}/common/inc" ) SET(CUDA_FLAGS -use_fast_math) From c8af27f9d9ac47577c3746d431647743139b28ad Mon Sep 17 00:00:00 2001 From: Changjie Date: Sat, 20 Aug 2022 16:08:55 +0200 Subject: [PATCH 2/2] Update README to illustrate how to enable CUDA. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 3bde4ceb0..b7d847957 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,15 @@ When you report USB issues, please attach relevant debug log from running the pr ## Installation +### Enable CUDA (optional) + +Install the latest CUDA Toolkit. Add option `-DENABLE_CUDA=ON -DNVCUDASAMPLES_ROOT=` to cmake to enable CUDA. CUDA samples could be downloaded [here](https://github.com/NVIDIA/cuda-samples.git). Below is an example to build on Linux if you download CUDA samples under the same directory as libfreenect2: + +``` sh +cd libfreenect2 && mkdir build && cd build +cmake .. -DENABLE_CXX11=ON -DENABLE_CUDA=ON -DNVCUDASAMPLES_ROOT=`pwd`/../../cuda-samples && make -j4 +``` + ### Windows / Visual Studio * Install UsbDk driver