Many variables with CXX in the name have a CUDA version with CUDA instead. For example, to set the C standard required for CUDA, if (NOT DEFINED CMAKECUDASTANDARD) set (CMAKECUDASTANDARD 11) set (CMAKECUDASTANDARDREQUIRED ON) endif. Many variables with CXX in the name have a CUDA version with CUDA instead. For example, to set the C standard required for CUDA, if (NOT DEFINED CMAKECUDASTANDARD) set (CMAKECUDASTANDARD 11) set (CMAKECUDASTANDARDREQUIRED ON) endif.
Makefiles are quite straightforward and easy to write (in reasonable situations). But GNU Make is not crossplafrom. CMake is cross-platform, cross-application (it can generate projects for different IDEs and Makefile itself).
It also allows you to split source directory and directory with intermediate files and compiled binary. Now CMake natively supports CUDA.
Here is CMakeLists.txt
example I use (simply place it next to your source files to try yourself):
This file automatically adds all sources in the same directory it is placed. I've also included lines for newer GPU architectures (feel free to uncomment them). I prefer to choose one to reduce compilation time. It aso switches on new (phah, new for 3 years :)) C++ standart.
Cuda Cmakelists
So, create CMakeLists.txt
file and place it in your sources directory (say src
). Then create bin
(choose another name if you want) directory next to src
. Change directory to bin
, generate Makefile
from CMakeLists.txt
and build it with ordinary make
:
Cuda Cmakelists
So, create CMakeLists.txt
file and place it in your sources directory (say src
). Then create bin
(choose another name if you want) directory next to src
. Change directory to bin
, generate Makefile
from CMakeLists.txt
and build it with ordinary make
:
Cmake Cuda Example Project
I've updated MPI part. Now it is correct.