NVRTC Compilation failed

I start getting another error now:

[ 4][  DISK CACHE]: Opened database: "/var/tmp/OptixCache_luciano/optix7cache.db"
[ 4][  DISK CACHE]:     Cache data size: "210.2 MiB"
terminate called after throwing an instance of 'std::runtime_error'
  what():  NVRTC Compilation failed.
/home/luciano/NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64/include/optix_7_device.h(36): catastrophic error: #error directive: Device code for OptiX requires at least C++11. Consider adding "--std c++11" to the nvcc command-line.

1 catastrophic error detected in the compilation of "/home/luciano/Desktop/rt_mpi_viewer/rt_mpi_viewer/cuda/raygen.cu".
Compilation terminated.

I found one relevant problem here , unfortunately didn’t help me.

I have a prayground_config.h.in file which indicated in the CMakeLists root as configure_file(prayground_config.h.in prayground_config.h ) The prayground_config.h.in looks like this:


#pragma once

#define RT_MPI_VIEWER_PTX_DIR "@RT_MPI_VIEWER_PTX_DIR@"
#define RT_MPI_VIEWER_CUDA_DIR "@RT_MPI_VIEWER_CUDA_DIR@"

// Include directories
#define RT_MPI_VIEWER_RELATIVE_INCLUDE_DIRS @RT_MPI_VIEWER_RELATIVE_INCLUDE_DIRS@
#define RT_MPI_VIEWER_ABSOLUTE_INCLUDE_DIRS @RT_MPI_VIEWER_ABSOLUTE_INCLUDE_DIRS@

// Signal whether to use NVRTC or not
#cmakedefine01 CUDA_NVRTC_ENABLED

// NVRTC compiler options
#define CUDA_NVRTC_OPTIONS @CUDA_NVRTC_OPTIONS@

The Build is a success, but I cannot see the -std c++11 in prayground_config.h in build folder. I Guess that is the problem. It looks like this:

...
// NVRTC compiler options
#define CUDA_NVRTC_OPTIONS  \
 "-arch", \
 "compute_60", \
 "-use_fast_math", \
 "-lineinfo", \
 "-default-device", \
 "-rdc", \
 "true", \
 "-D__x86_64",

To add the "--std c++11" in #define CUDA_NVRTC_OPTIONS \ , in CMakeLists Root file I did something like this, especially see the second code snippet:

if(NOT PASSED_FIRST_CONFIGURE)
	list(FIND CUDA_NVCC_FLAGS "-arch" index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS -arch sm_60 )
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()

	# bm (c++11 for cuda nvcc command line )
	set(flag "--std c++11")#"--std c++11")
	list(FIND CUDA_NVCC_FLAGS ${flag} index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS ${flag})
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()


	set(flag "--use_fast_math")
	list(FIND CUDA_NVCC_FLAGS ${flag} index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS ${flag})
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()

	set(flag "-lineinfo")
	list(FIND CUDA_NVCC_FLAGS ${flag} index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS ${flag})
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()

	if (CUDA_VERSION VERSION_LESS "3.0")
		set(flag "--keep")
		list(FIND CUDA_NVCC_FLAGS ${flag} index)
		if(index EQUAL -1)
			list(APPEND CUDA_NVCC_FLAGS ${flag})
			set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
		endif()
	endif()

...

#  ERROR: catastrophic error: #error directive: Device code for OptiX requires at least C++11. Consider adding "--std c++11" to the nvcc command-line.
	if(CMAKE_CXX_STANDARD GREATER 20)
		set(RT_MPI_VIEWER_NVRTC_CXX "-std=c++20")
	else()
		set(RT_MPI_VIEWER_NVRTC_CXX "")
	endif()
	set(CUDA_NVRTC_FLAGS ${RT_MPI_VIEWER_NVRTC_CXX} -arch compute_60 -std c++11 -use_fast_math -lineinfo -default-device -rdc true -D__x86_64 CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
endif(NOT PASSED_FIRST_CONFIGURE)

mark_as_advanced(CUDA_NVRTC_FLAGS)

...
# Build a null-terminated option list for NVRTC
set(CUDA_NVRTC_OPTIONS)
foreach(flag ${CUDA_NVRTC_FLAGS})
	set(CUDA_NVRTC_OPTIONS "${CUDA_NVRTC_OPTIONS} \\\n \"${flag}\",")
endforeach()
set(CUDA_NVRTC_OPTIONS "${CUDA_NVRTC_OPTIONS}")

Any suggestion?