需要CUDA库的工程,其CMakeLists.txt需要额外增加的代码
添加
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
if (CUDA_VERSION VERSION_LESS "11.0")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -std=c++11 -Wno-deprecated-gpu-targets)
else ()
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -std=c++14 -Wno-deprecated-gpu-targets)
endif ()
link_libraries(${CUDA_INCLUDE_DIRS})
find_library(NVINFER NAMES nvinfer)
find_library(NVPARSERS NAMES nvparsers)
find_library(NVONNXPARSERS NAMES nvonnxparser)
CUDA_ADD_EXECUTABLE (pc_viewer main.cpp ${SOURCE_LIST})
target_link_libraries (pc_viewer
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
${CUDA_cusparse_LIBRARY}
${CUDA_cusparse_LIBRARY}
${NVINFER}
${NVONNXPARSERS}
yaml-cpp)
使用CUDA_ADD_EXECUTABLE
代替原来的add_executable