title: CUDA compile problems on Windows, Cmake error: No CUDA toolset found
body: <p>so I've been successfully working on my CUDA program on my Linux but I would like to support Windows platform as well. However, I've been struggling with correctly compiling it. I use :</p>
  
  <ul>
  <li>Windows 10 </li>
  <li>Cmake 3.15</li>
  <li>Visual Studio 2017 </li>
  <li>CUDA Toolkit 10.1</li>
  </ul>
  
  <p>When using the old deprecated Cmake CUDA support of using <code>find_package(CUDA 10.1 REQUIRED)</code> it correctly reports the correct path to the toolkit when using it. However, it is my understanding that the latest Cmake does not properly support the old method anymore and that <code>cuda_add_library</code>etc don't properly link anymore. So I have reformatted my 'CMakeLists.txt' file to the following based on <a href="https://devblogs.nvidia.com/building-cuda-applications-cmake/" rel="noreferrer">this</a>:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
  project(myproject LANGUAGES CXX CUDA)
  
  add_library(mylib SHARED mycudalib.cu)
  
  # My code requires C++ 11 for the CUDA library, not sure which ones of these 
  # will do the trick correctly. Never got the compiler this far.
  target_compile_features(mylib PUBLIC cxx_std_11)
  SET(CMAKE_CXX_STANDARD 11)
  SET(CMAKE_CUDA_STANDARD 11)    
  
  
  set_target_properties( mylib PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
  
  add_executable(test_mylib test.cpp)
  
  target_link_libraries(test_mylib mylib ${CUDA_CUFFT_LIBRARIES})
  </code></pre>
  
  <p>However, I get the following error from line 2:</p>
  
  <pre><code>CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineCompilerId.cmake:345 (message):
    No CUDA toolset found.
  Call Stack (most recent call first):
    C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
    C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineCUDACompiler.cmake:72 (CMAKE_DETERMINE_COMPILER_ID)
    CMakeLists.txt:2 (project)
  </code></pre>
  
  <p>I've tried a variation of suggestions online such as adding the following to 'CMakeLists.txt':</p>
  
  <pre><code>set(CMAKE_CUDA_COMPILER "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin/nvcc")
  </code></pre>
  
  <p>or adding the following variable to Cmake:
  <a href="https://i.stack.imgur.com/R3ldw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/R3ldw.png" alt="enter image description here"></a></p>
  
  <p>This is the 'CMakeLists.txt' file I use on Linux to compile succesfully. The difference is there I use Cmake 3.5 and CUDA Toolkit 9.0: </p>
  
  <pre><code>cmake_minimum_required(VERSION 3.5)
  project( myproject)
  find_package(CUDA 9.0 REQUIRED)
  if(CUDA_FOUND)  
          list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
  endif(CUDA_FOUND)
  
  cuda_add_library(mylib SHARED mycudalib.cu)
  cuda_add_executable(test_mylib test.cpp)
  target_link_libraries(test_mylib mylib ${CUDA_CUFFT_LIBRARIES})
  </code></pre>