Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling CUDA kernel separately from host CMake

Tags:

cuda

cmake

I heard that it is better to compile CUDA kernels separately from host code. How do I do that with cmake? I am an absolute beginner in Cmake.

Thanks

like image 616
Peter Avatar asked Mar 26 '26 06:03

Peter


1 Answers

As I know it is not possible, unless you do some hacks, with only one cmake command. You could write two CMakeLists.txt one for the CUDA code and one for host code. In the file for the host code you can add the CUDA stuff as library. After that you can write a shell script which executes the two commands for each CMakeLists.txt.

I usually do this with make. There I have two targets for CUDA and host code each compiled into an object file. A third target executes the others and then links the object files to an executable.

like image 66
ipa Avatar answered Mar 28 '26 01:03

ipa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!