cmake: Target-specific preprocessor definitions for CUDA targets seems not to work

Posted by Nils on Stack Overflow See other posts from Stack Overflow or by Nils
Published on 2010-05-16T08:39:46Z Indexed on 2010/05/16 8:50 UTC
Read the original article Hit count: 319

Filed under:

I'm using cmake 2.8.1 on Mac OSX 10.6 with CUDA 3.0.

So I added a CUDA target which needs BLOCK_SIZE set to some number in order to compile.

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

set_target_properties(SimpleTestsCUDA PROPERTIES COMPILE_FLAGS -DBLOCK_SIZE=3)

When running make VERBOSE=1 I noticed that nvcc is invoked w/o -DBLOCK_SIZE=3, which results in an error, because BLOCK_SIZE is used in the code, but defined nowhere. Now I used the same definition for a CPU target (using add_executable(...)) and there it worked.

So now the questions: How do I figure out what cmake does with the set_target_properties line if it points to a CUDA target? Googling around didn't help so far and a workaround would be cool..

© Stack Overflow or respective owner

Related posts about cmake