cmake - 在最新的 CMAKE 中找不到 CUDA_INCLUDE_DIRS

标签 cmake cuda

这个问题在这里已经有了答案:





Listing include_directories in CMake

(3 个回答)


2年前关闭。




由于在 CMAKE 3.10 中,默认情况下支持 CUDA 宏( https://cmake.org/cmake/help/latest/module/FindCUDA.html )。

但我找不到变量 CUDA_INCLUDE_DIRS

cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(cmake_and_cuda LANGUAGES CXX CUDA)

message(${CUDA_INCLUDE_DIRS})

错误是
-- The CXX compiler identification is GNU 5.4.0
-- The CUDA compiler identification is NVIDIA 10.0.130
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc -- works
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
CMake Error at CMakeLists.txt:7 (message):
  message called with incorrect number of arguments


-- Configuring incomplete, errors occurred!
See also "/home/tumh/code-samples/posts/cmake/build/CMakeFiles/CMakeOutput.log".

任何的想法?

最佳答案

只需使用 ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} .

在所有 .cu src 文件中,无需手动添加

include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}),

因为 CMake 会为你做这件事。

但是对于 .cpp src 文件,如果您需要 include <cuda_runtime.h> ,必须手动添加
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) 

在您的 CMakeLists.txt 中。

关于cmake - 在最新的 CMAKE 中找不到 CUDA_INCLUDE_DIRS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55741286/

相关文章:

cuda - 我可以将现有的可分页内存转换为固定内存吗?

c++ - 永恒赋值运算符调用循环C++模板类

c++ - CMake + CUDA + OpenCV

c++ - iOS 框架 : image not found

visual-studio - AVX512 和 MSVC 预处理器符号

c++ - 在tsan_libdispatch_mac.cc期间,使用cmake进行的LLVM构建失败。 “Error: conflicting types for …”

memory - CUDA 边界检查器?

android - 组织 SDK + NDK 模块的最佳方式是什么

cmake - 如何配置 cmake 以获取非默认的可执行文件

c++ - 将 Eigen::SparseMatrix 转换为 cuSparse,反之亦然