Search code examples
cudacmakeroscatkin

CUDA ROS CMake nvcc Fatal


I get a generic error when I try to run catkin build:

  CMake Error at robot_cuda_lib_generated_matrix.cu.o.cmake:206 (message):
  Error generating
  /.../catkin_ws/build/robot/CMakeFiles/robot_cuda_lib.dir/src/./robot_cuda_lib_generated_matrix.cu.o

or if I try to build in the folder itself:

nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified

I know the matrix.cu file works. I pulled it out of the CUDA tutorial they make, and it works fine if I put it in another project. My leading theory is that there is some conflict somehow with one of my other packages. Or perhaps my CMakeLists.txt is just wrong somewhere. I've tried quite a few changes and fixes. This is the current version:

cmake_minimum_required(VERSION 2.8.11)
project(robot)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  pcl_ros
)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")

find_package(OpenCV REQUIRED)
find_package(efusion REQUIRED)
find_package(Qt4 REQUIRED)
find_package(Qwt REQUIRED)
find_package(VTK 7 REQUIRED)
find_package(CUDA REQUIRED)

include(${QT_USE_FILE})
include(${VTK_USE_FILE})
include(FindCUDA)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES robot
#  CATKIN_DEPENDS roscpp rospy std_msgs
#  DEPENDS system_lib
)

include_directories(
  include
  include/gplvm
  ${catkin_INCLUDE_DIRS}
  ${EFUSION_INCLUDE_DIR}
  ${EIGEN_INCLUDE_DIRS}
  # include this for ui_h
  ${CMAKE_CURRENT_BINARY_DIR}
  ${QWT_INCLUDE_DIR}
  #/usr/local/cuda/include
)

qt4_wrap_cpp(MOC_SRCS
    include/gplvm_plot.hpp
    include/parameter_handler.hpp
    include/robot.hpp
)

qt4_wrap_ui(UI_HDRS
    ui/parameter_handler.ui
    ui/robot.ui
)

file(GLOB robot_cuda "src/*.cu")
file(GLOB robot_srcs "src/*.cpp" "src/kernel/*.cpp" "src/*.cu")
file(GLOB robot_hdrs "include/*.h" "include/*.hpp" "include/kernel/*.h" "include/kernel/*.hpp")

cuda_add_library(robot_cuda_lib ${robot_cuda} ${robot_hdrs})

cuda_add_executable(robot_node ${robot_srcs} ${robot_hdrs} ${MOC_SRCS} ${UI_HDRS})

target_link_libraries(robot_node
   ${catkin_LIBRARIES}
   ${OpenCV_LIBS}
   ${EFUSION_LIBRARY}
   ${Eigen_LIBRARIES}
   ${QWT_LIBRARY}
   ${QT_LIBRARIES}
   ${VTK_LIBRARIES}
)

Is it possible one of the other packages is breaking the build?


Solution

  • Indeed, some package did not agree with CUDA. I moved the cuda_add_library call to before the find_package calls and it cmade and made fine.