mkmf-cu is a gem to write Ruby extensions in C/C++ with NVIDIA CUDA. It consists of a simple wrapper command for nvcc and a monkey patch for mkmf.
Instead of require "mkmf", just
require "mkmf-cu"
By requiring "mkmf-cu", compiler commands defined in mkmf will be replaced with mkmf-cu-nvcc, a command included in this gem.
When mkmf-cu-nvcc is called with arguments for gcc or clang, it convert them to ones suitable for nvcc and execute nvcc with them.
For example,
mkmf-cu-nvcc -I. -fno-common -pipe -Os -O2 -Wall -o culib.o -c culib.cu
will execute
nvcc -I. -O2 -o culib.o -c culib.cu --compiler-options -fno-common --compiler-options -Wall
When the suffix of the name of a file containing CUDA code is not .cu, you must add the option "-x cu" to $CFLAGS or $CXXFLAGS in extconf.rb.