Cmake: Preprocessor definitions for targets for CUDA targets don't seem to work

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

So, I added a CUDA target for which BLOCK_SIZE is set to some number to compile.

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

set_target_properties(SimpleTestsCUDA PROPERTIES COMPILE_FLAGS -DBLOCK_SIZE=3)

At startup, make VERBOSE=1I noticed that nvccw / o is being called -DBLOCK_SIZE=3, which leads to an error, because it is BLOCK_SIZEused in the code, but not defined anywhere. Now I used the same definition for the target processor (using add_executable(...)), and there it worked.

So now the questions are: How do I find out what cmakedoes a line do set_target_propertiesif it points to a CUDA target? Riding around has not helped so far, and a workaround would be cool.

+3
source share
2

, - "OPTIONS -DBLOCK_SIZE = 3" cuda_add_executable. , :

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

cuda_add_executable:

SET(CUDA_NVCC_FLAGS -DBLOCK_SIZE=3)
+4

, , remove_definitions:

remove_definitions(-DBLOCK_SIZE=3)
add_definitions(-DBLOCK_SIZE=32)

, .

0

Source: https://habr.com/ru/post/1745619/


All Articles