Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CUDA with visual studio and cmake

I am working with CUDA 8.0 and Visual Studio 2013. Until now I have been building my VS-Solutions with CMake and it is working pretty well. Normally a cuda project is build with following code snippet:

FIND_PACKAGE(CUDA REQUIRED)
INCLUDE_DIRECTORIES( ${CUDA_INCLUDE_DIRS})
link_directories(${CUDA_INCLUDE_DIRS}/../lib/x64)

The CUDA-project is working, compiling and running without any problems. But I am missing the CUDA C/C++ field in the project properties. When I create a VS-Solution directly in VS, I can choose NVIDIA/ CUDA 8.0 and the properties are there (as you can see in the picture below) enter image description here

Question: Is it possible to generate a project with CMake and with the CUDA properties project option?

Thanks and I hope my question is clear.

like image 216
Soeren Avatar asked Jan 17 '17 14:01

Soeren


1 Answers

Some month passed since I asked myself this question... And now the new version of CMake enables CUDA as a first-class language with version 3.8.

This means, now it is possible to create CUDA targets with this simple command (doku):

enable_language(CUDA) 

This functionality of CMake offers to create CUDA-targets with using the cmake-commands add_executable or add_library without the need for using the find_package(CUDA) or cuda_add_executable() commands.

However, CMake's Version 3.8 does not include the support for Visual Studio's IDE - But Version 3.9 does (Hooray!!). The properties project options in VS are available now.

Conclusion: If you work with CUDA and Visual Studio, it will be absolutely worth it to switch to CMake 3.9 and this great new functionality.

like image 83
Soeren Avatar answered Oct 31 '22 01:10

Soeren