CMake + Cuda: compile cpp files in Cuda-mode (--x=cu)

Viewed 2009

Suppose I have a file, let's call it foo.cpp, my goal is to compile this file with nvcc in cuda mode. From the command-line this can be easily accomplished by invoking:

nvcc --x=cu foo.cpp

What I'm struggling with, is to get CMake to do this exact same thing. It turns out that the CMake command cuda_add_executable(foo foo.cpp) will filter the *.cpp files and use the c++-compiler (instead of nvcc).

Note that renaming all the files to *.cu is not an option as the codebase has to also support non-cuda builds.

1 Answers
Related