使用cmake编译Cuda

时间:2014-06-26 21:03:03

标签: c++ cuda cmake

我正在尝试使用cmake编译一个简单的测试cuda程序。一开始我发现了这个例子[1],但它不起作用。生成的输出是

 cmake ../
 -- The C compiler identification is GNU 4.6.3
 -- The CXX compiler identification is GNU 4.6.3
 -- Check for working C compiler: /usr/bin/gcc
 -- Check for working C compiler: /usr/bin/gcc -- works
 -- Detecting C compiler ABI info
 -- Detecting C compiler ABI info - done
 -- 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
 -- Could NOT find CUDA (missing:  CUDA_INCLUDE_DIRS) (found version "6.0") 
    CUDA not found, doing something alternatively
 -- Configuring done
 -- Generating done
 -- Build files have been written to: ...

所以我添加了“set(CUDA_INCLUDE_DIRS”/ usr / local / cuda / include /“$ {CUDA_INCLUDE_DIRS})”,现在CMakeLists.txt包含

cmake_minimum_required(VERSION 2.8)
project(CUDACMAKETEST)
find_package(CUDA)
set(CUDA_INCLUDE_DIRS "/usr/local/cuda/include/" ${CUDA_INCLUDE_DIRS})
if (CUDA_FOUND)
    message("CUDA found, using device squaring!")
    add_subdirectory(src.gpu)
else()
    message("CUDA not found, doing something alternatively")
    add_subdirectory(src.cpu)
endif()
set(CMAKE_CXX_FLAG "-g -Wall")

但我得到相同的输出。怎么了?路径应该是正确的。

[1] https://github.com/AndiH/CMake/tree/master/CMake%2BCUDA

0 个答案:

没有答案