I'm trying to get a CUDA project to compile using CMake and Visual Studio 2017, but the build fails, details below.
System:
Windows 10 Pro x64
Visual Studio Enterprise 2017 Version 15.3.2
CUDA 9 RC (Version 9.0.103)
CMake 3.9.1 (Generator: Visual Studio 15 2017 Win64)
The dummy project:
CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(vs17cuda)
# Cuda is always required
find_package(CUDA REQUIRED)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11" )
add_subdirectory(src)
src/CMakeLists.txt
cuda_add_executable(vs17cuda main.cu)
set_target_properties(vs17cuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries(vs17cuda ${CUDA_LIBRARIES})
src/main.cu
#include <cuda_runtime.h>
__global__ void DummyKernel()
{
//do nothing
}
int main (int argc, char * argv[]) {
DummyKernel<<<4, 4>>>();
}
Console output: (german messages translated to english)
1>------ Build started: Project: vs17cuda, Configuration: Debug x64 ------
1>Building NVCC (Device) object src/CMakeFiles/vs17cuda.dir/Debug/vs17cuda_generated_main.cu.obj
1>Failed to run C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/bin/cl.exe (File not found).
1>
1>).
1>CMake Error at vs17cuda_generated_main.cu.obj.Debug.cmake:222 (message):
1> Error generating
1> C:/Users/Sebastian/Documents/C++/vs17cuda/build/src/CMakeFiles/vs17cuda.dir//Debug/vs17cuda_generated_main.cu.obj
1>
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
1>Done building project "vs17cuda.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
How can the build be fixed?