What is the best way to support CUDA projects?
CUDA, as a language, is essentially C++ with extensions. During compilation nvcc (Nvidia CUDA Compiler) is compiling all gpu specific code and replaces all non C++ constructs with valid C++ the result is than handed over to a standard C++ compiler (usually gcc).
Because of this I originally thought it would be sufficient to add a nvcc toolset to premake.
So I basically copied clang.lua and prefixed some flags that nvcc does not understand with -Xcompiler (this flag tells nvcc to hand over the next flag to the C++ compiler).
And there the problems started: .cu files are not handed to nvcc because path.iscppfile does not, and is right to do so, classify .cu files as C++ files.
To get an idea of what other problems will arise I just patched path.iscppfile to accept .cu files.
So far just one other issue arose: the dependency generation in makefiles is currently hardcoded as -MF "$(@:%%.gch=%%.d)" one of the flags nvcc does not understand.
There is a similar flag for nvcc:
> nvcc --help
...
--dependency-target-name <target> (-MT)
Specify the target name of the generated rule when generating a dependency
file (see '--generate-dependencies').
...
Changing the flag results in a successful build :-)
However, nvcc is generating a lot of other dependency files within the build directory. So far I haven't figured out how to specify their location.
Which brings me back to the original question - after reading this, do you think adding nvcc as a toolset is a valid approach to support CUDA projects?
And if so would somebody be willing to help me finalizing this (like answering some questions via chat).
The "Adding a New Toolset" section in the wiki couldn't explain everything to me ;-)
Thanks,
Nils