How to use CUDA with rosbuild
Hi,
I am trying to integrate CUDA in my ros package (which is not catkinized) and have some problems. I believe, that I have to use cuda_add_library and cuda_add_executable in my CMakeLists.txt and after that target_link_libraries. If I do that, for some reason I get linking errors because the libraries have not been linked, it says it doesn't know about ros::spin for instance. If instead, I use rosbuild_add_library and rosbuild_add_executable, there is some CUDA related linking issue. I append the important bits of the CMakeLists file. If I compile without CUDA support, everything works. I would be grateful for any help.
if(SUPPORT_CUDA)
find_package(CUDA QUIET REQUIRED)
include_directories(${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc)
add_definitions(-DCUDA_BUILD -DBT_USE_DOUBLE_PRECISION)
list(APPEND SOURCES bar.cu)
else()
MESSAGE(STATUS "cuda not found")
endif()
if(SUPPORT_CUDA)
cuda_add_library(${PROJECT_NAME} SHARED ${SOURCES})
cuda_add_executable(main ${PROJECT_SOURCE_DIR}/src/main.cpp)
else()
rosbuild_add_library(${PROJECT_NAME} SHARED ${SOURCES})
rosbuild_add_executable(main ${PROJECT_SOURCE_DIR}/src/main.cpp)
ENDIF()
target_link_libraries(${PROJECT_NAME} ${EXTERNAL_LIBS})
target_link_libraries(main ${PROJECT_NAME})