[CMake] CMake and CUDA: Target specific macro definition?

Nils Brünggel n.bruenggel at gmail.com
Wed May 19 02:28:52 EDT 2010


Hi

I'm using CMake to build my CUDA projects and I would like to add some
options specifically for CUDA targets. For example to define a macro
(-D when using gcc or nvcc) So I tried the following:

cuda_add_executable(SimpleTestsCUDA
                    SimpleTests.cu
                    BlockMatrix.cpp
                    Matrix.cpp
)

set_target_properties(SimpleTestsCUDA PROPERTIES COMPILE_FLAGS -DBLOCK_SIZE=3)

After running make VERBOSE=1 I saw that nvcc is invoked w/o the macro
defined above. (-DBLOCK_SIZE=3) The same thing worked for a CPU target
with add_executable.

Somebody also recommended me to try:

cuda_add_executable(SimpleTestsCUDA
                SimpleTests.cu
                BlockMatrix.cpp
                Matrix.cpp
                OPTIONS -DBLOCK_SIZE=3
)

Which didn't work either.

I've tested this on my Mac (OSX 10.6) with CMake 2.8.1 and CUDA 3.0.

Nils


More information about the CMake mailing list