ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

in your CMakeLists.txt:

    find_package( CUDA REQUIRED 

 # set CUDA_NVCC_FLAGS as you would do with CXX/C FLAGS                        
  set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -DMY_DEF=1")
  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMY_DEF=1" )
  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMY_DEF=1" )

 # only necessary if you wish to create a lib
  set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
  set(BUILD_SHARED_LIBS ON)

# cuda compile GPU_CODE for executable
  cuda_compile(  HELLO_CU_O src/hello.cu )

## create an executable
## can add other (none CUDA) cpp files here
  cuda_add_executable( hello_exec ${LINE_PROFILER_CU_O} )
  target_link_libraries( hello_exec ${catkin_LIBRARIES} )
  add_dependencies( hello_lib ${PROJECT_NAME}_generate_messages_cpp  ${LINE_PROFILER_CU_O} )

## if message headers needed 
  add_dependencies( hello_lib ${PROJECT_NAME}_generate_messages_cpp )

### or create a lib 
  cuda_add_library( ${PROJECT_NAME} src/lib_cuda_code.cu src/libe_none_cuda_code.cpp )
  target_link_libraries( ${PROJECT_NAME} ${catkin_LIBRARIES}  )

## if message headers needed 
  add_dependencies( ${PROJECT_NAME} ${PROJECT_NAME}_generate_messages_cpp )