Specify CUDA compiler in CMake
<p>I am trying to build a cuda project using clang-3.9 based on the following <a href="http://llvm.org/docs/CompileCudaWithLLVM.html#prerequisites" rel="noreferrer">documentation</a>. But I want to use cmake to build my project. I have already set CMAKE_CC_COMPILER and CMAKE_CXX_COMPILER to clang and clang++ respectively.</p>

<p>But the problem is that if I use  </p>

<pre><code>file(GLOB_RECURSE CUDA_SOURCES "./*.cu")
CUDA_ADD_LIBRARY(Benchmarks_CUDA ${CUDA_SOURCES})
</code></pre>

<p>in my CMakeList.txt then cmake will be using nvcc compiler by default. But instead I want to use clang for compiling .cu files.</p>

<p>Instead if I use </p>

<pre><code>add_library (Benchmarks_CUDA ${CUDA_SOURCES})
</code></pre>

<p>then I will get an error </p>

<pre><code>CMake Error: Cannot determine link language for target "Benchmarks_CUDA".
CMake Error: CMake can not determine linker language for target: Benchmarks_CUDA
</code></pre>

<p>Can someone tell me how to use cmake to build .cu files using clang.</p>