3
votes

Is there a flag I can pass nvcc to treat a .cpp file like it would a .cu file? I would rather not have to do a cp x.cpp x.cu; nvcc x.cu; rm x.cu.

I ask because I have cpp files in my library that I would like to compile with/without CUDA based on particular flags passed to the Makefile.

1

1 Answers

8
votes

Yes, referring to the nvcc documentation the flag is -x:

nvcc -x cu test.cpp

will compile test.cpp as if it were a test.cu file (i.e. pass it through the CUDA toolchain)