<div dir="ltr"><div>Hi all,</div><div><br></div><div>With the new way CMake is treating CUDA codes, now we can do:</div><div><br></div><div>project(foo LANGUAGES CXX CUDA)<br></div><div><br></div><div>and can do:</div><div><br></div><div>add_executable(foo_cuda <a href="http://foo.cu">foo.cu</a>) # will use NVCC</div><div>add_executable(foo_cpp foo.cpp) # will use host compilers</div><div><br></div><div>Now since CUDA can take *.cpp files as extension (see <a href="https://stackoverflow.com/questions/26208784/cuda-cpp-files">https://stackoverflow.com/questions/26208784/cuda-cpp-files</a>), is there a away to flip the compiler using one single source files? Something along the line of:</div><div><br></div><div>if(CUDA_FOUND)</div><div>  add_executable_with_nvcc(foo_cuda foo.cpp) # of course this doesn't exist<br></div><div>else(CUDA_FOUND)</div><div>  add_executable_with_cpp(foo_cpp foo.cpp) # neither does this<br></div><div>endif(CUDA_FOUND)</div><div><br></div><div>Or would anyone suggest a work-around? With the help of add_definitions, I can manually compile a host and device executable - just need to integrate this final step into the project.</div><div><br></div><div>Thanks,</div><div>Quang<br></div><div><br></div></div>