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..
I think the best way to do this is by adding "OPTIONS -DBLOCK_SIZE=3" to cuda_add_executable. So your line would look like this:
Or you can set it before cuda_add_executable:
The only workaround I found so far is using remove_definitions:
Doing this before a target seems to help.