Compilation error: adding --extended-lambda nvcc flag without result

Hello,

I’m trying to compile a raytracing “hello world” example from NanoVDB, but while building my .cu.o file, I get this error:

make
#[...]
[ 20%] Building CUDA object CMakeFiles/my_lib.dir/src/BenchKernels_nano.cu.o
/apps/all/CUDA/12.2.0/bin/nvcc -forward-unknown-to-host-compiler  --options-file CMakeFiles/my_lib.dir/includes_CUDA.rsp -std=c++17 -MD -MT CMakeFiles/my_lib.dir/src/BenchKernels_nano.cu.o -MF CMakeFiles/my_lib.dir/src/BenchKernels_nano.cu.o.d -x cu -rdc=true -c /home/me/projects/05_vdb_crossover/src/BenchKernels_nano.cu -o CMakeFiles/my_lib.dir/src/BenchKernels_nano.cu.o
/home/me/libs/openvdb/nanovdb/nanovdb/util/cuda/CudaNodeManager.cuh(42): error: __host__ or __device__ annotation on lambda requires --extended-lambda nvcc flag
      cudaLambdaKernel<<<1, 1, 0, stream>>>(1, [=] __attribute__((device))(size_t) {
#[...]

I tought rebuilding my project with -DCUDA_NVCC_FLAGS="--extended-lambda" would help, but did not. So I tried to rebuild the whole library OpenVDB with the flag, and it didn’t help, the error message didn’t change at all.

Where else coul I look for the problem? My CMakeCache says CUDA_NVCC_FLAGS:STRING=--extended-lambda, so it somehow passes through, but does nothing (according to the same error)

Sorry to bother you with this, I’m just starting with C++ and CMake.

The compile command is already shown in the output you have provided. It does not contain the necessary compiler switch (--extended-lambda). You’ll need to continue working on your CMake configuration to get that to actually appear in the compile command. I don’t have a specific CMake recipe for you, but there are numerous questions about how to use CMake on various forums.