Since I usually develop in C++ and want to increase my knowledge of CMake, I decided to try if I could build this app using CMake instead of the provided Makefile.
Disclaimer: I am a total CUDA and CMake noob, but I wanted to record this process and somebody might just find it useful. This post was very useful to me.
This is the result we are aiming for:
And here I decided I shouldn't go line by line in the CMakeLists.txt file, firstly because I don't fully understand what each line is doing, so it would be hypocritical for me to explain to you, and secondly because I don't feel like formatting all the text with color. I leave you to explore tweaks and redundancies. I yet need to understand the difference between using something like OpenGL::OpenGL and ${OPENGL_LIBRARIES}
I did find a few gotchas:
* first in the inclusion of the common header code located in the CUDA_SAMPLES folder. You can see that is taken care of with the include_directories directive
* Then linking against OpenGL I struggled for 15 mins or so until finding the instructions that properly linked against it.
* Then with CUDA, despite finding the library, CMake was not finding nvcc, the CUDA compiler.
I had to manually set the environment variable CUDACXX to point to my nvcc binary. I found about this when I added lines 5-7.
So I hope somebody finds this useful. I guess I am not the only person trying to port CUDA applications from Makefile to CMake. Else, I will probably find it useful in the future.
Regards,
M.L.


No hay comentarios:
Publicar un comentario