Ask Your Question
0

CMake Error ... No SOURCES given to target:

asked 2020-06-29 04:41:30 -0500

Alessandro Melino gravatar image

updated 2020-06-29 05:30:44 -0500

Hello.

I am trying to compile a custom package but I am getting some errors with CMake. The error is the following:

-- +++ processing catkin package: 'kate_global'
-- ==> add_subdirectory(kate_global)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- kate_global: 2 messages, 0 services
-- Configuring done
CMake Error at kate_global/CMakeLists.txt:140 (add_executable):
  Cannot find source file:

  catkin::rosconsole::wrapped-linker-option0


  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at kate_global/CMakeLists.txt:140 (add_executable):
  No SOURCES given to target: control_node_kate


-- Build files have been written to: /home/pi/catkin_ws/build
Invoking "cmake" failed

I don't know what is wrong so I attach here CMakeLists and the directory of the files of executables:

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(kate_global)

find_package(catkin REQUIRED COMPONENTS
  controller_manager
  diff_drive_controller
  roscpp
  rospy
  message_generation
  std_msgs
  move_base
)

 add_message_files(
   FILES
   enc_msg.msg
   CAN.msg
)

 generate_messages(
   DEPENDENCIES
   std_msgs
 )

catkin_package()

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(
  control_node_kate src/kate_control_loop.cpp src/kate_hw_interface.cpp
  ${catkin_LIBRARIES}
)

target_link_libraries(
  control_node_kate
 ${catkin_LIBRARIES}
 )

install(TARGETS control_node_kate
   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
 )

Files listed

pi@raspberrypi:~/catkin_ws/src/kate_global/src $ ls -l
total 12
-rwxrwxrwx 1 pi pi 2450 Jun 11 12:53 kate_control_loop.cpp
-rwxrwxrwx 1 pi pi 8060 Jun 11 13:17 kate_hw_interface.cpp

I am working on Raspberry Pi OS (64 bits) using ROS Noetic.

Thanks in advance.

Best regards. Alessandro

edit retag flag offensive close merge delete

Comments

Please remove all the comments from your CMakeLists.txt. They are not needed and make it unnecessarily long.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-29 05:24:34 -0500 )edit

Done. Thanks for the advice.

Alessandro Melino gravatar image Alessandro Melino  ( 2020-06-29 05:30:55 -0500 )edit

please refer to this answer https://answers.ros.org/question/2444....

Jayanth gravatar image Jayanth  ( 2020-06-29 06:53:31 -0500 )edit

Respect to that answer, just the control_loop.cpp has the main entry, the hw_interface.cpp is called by an include file. Maybe I have to delete the add_executable of hw_interface? By the way, I have other similar project with that two add_executable and it compiles, so I don't know what is going wrong in this project.

Alessandro Melino gravatar image Alessandro Melino  ( 2020-06-30 04:36:58 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-01 06:51:01 -0500

Alessandro Melino gravatar image

Solved creating a package from scratch using:

catkin_create_pkg my_package std_msgs rospy roscpp

Best regards. Alessandro

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-06-29 04:41:30 -0500

Seen: 71 times

Last updated: Jul 01