Useful as I’m using CLion sometimes for doing CUDA stuff..
CMake is a popular option for cross-platform compilation of code. CMake has support for CUDA built in, so it is pretty easy to build CUDA source files using it.
Let us assume that I want to build a CUDA source file named
src/hellocuda.cu. To build this using CMake, we create a file named
CMakeLists.txt containing these lines:
To build our program on Linux, we first run
cmake to generate a
Makefile and use that
Makefile to build and run. On Windows,
cmake would generate a Visual Studio solution, that can be used to build the code.
Steps to build and run program on Linux:
Any non-trivial CUDA program will need special compilation flags, include directories, library directories and multiple source files. The
CMakeLists.txt shown below is an example of how to configure all these features:
nvcc calls both the host compiler and device compiler by itself on both
View original post 102 more words