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

catkin build does not place executable in devel folder

asked 2021-07-20 11:10:51 -0600

Andreas Ziegler gravatar image

I have a ROS1 noetic project with the following CMakeLists.txt.

cmake_minimum_required(VERSION 3.0.2)
project(ball_tracker_ros)

find_package(ball_tracker REQUIRED)

find_package(catkin REQUIRED roscpp prophesee_event_msgs)

add_executable(${PROJECT_NAME} src/ball_tracker_ros.cpp)

# Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES} )
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES}
                      ball_tracker::ball_tracker)

target_include_directories(
  ${PROJECT_NAME}
  PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
         $<INSTALL_INTERFACE:include>
  PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${catkin_INCLUDE_DIRS})

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)

target_compile_options(
  ${PROJECT_NAME}
  PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
          -pipe
          -march=native
          -Wall
          -Wextra
          $<$<CONFIG:Release>:-O3>>
          $<$<CONFIG:Debug>:-g
          -ggdb3
          -Og>>
          $<$<CXX_COMPILER_ID:MSVC>:
          $<$<CONFIG:Debug>:/Od
          /Wall
          /Zi>>)

When I run catkin build, the executable (ball_tracker_ros) is only in build/ball_tracker_ros/ and not in devel/lib/ball_ttracker_ros (the folder devel/lib/ball_ttracker_ros does not exist at all). Since I don't get any compilation/linking errors/warning and the binary is in the build folder, compilation seems fine. In the same workspace I also have this package. The executable of this package end in devel/lib/prophesee_ros_driver. Therefore catkin build seems to work and I expect the problem witin the package ball_tracker_ros.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-07-21 02:38:58 -0600

Andreas Ziegler gravatar image

The solution was to add

catkin_package(
  INCLUDE_DIRS include/${PROJECT_NAME}/
  LIBRARIES ${PROJECT_NAME}
  CATKIN_DEPENDS roscpp prophesee_event_msgs
)

before add_executable(...).

I'm having a hard time with following the modern CMake style and the custom-made ROS CMake extensions (which appear to follow more the old CMake style). Does anyone have a best practice for this? ROS2 seems to follow more the modern CMake style.

edit flag offensive delete link more

Comments

Order matters with CMakeLists.txt and Catkin (actually, it always matters with CMake, it's just that with Catkin, it's easier to run into the kinds of hickups you encountered).

See wiki/catkin/CMakeLists.txt: Overall Structure and Ordering.

I'm having a hard time with following the modern CMake style and the custom-made ROS CMake extensions (which appear to follow more the old CMake style). Does anyone have a best practice for this?

there isn't really anything to "best practice" here.

As you've noticed, Catkin was written (quite some time ago) to work-around some of the deficiencies of old CMake versions. As Catkin serves ROS 1, it's not seeing any new development. CMake is being developed, so there is going to be more-and-more divergence between what "modern CMake" suggests you do and what we do in "old CMake" CMakeLists.txt with Catkin.

gvdhoorn gravatar image gvdhoorn  ( 2021-07-23 09:48:12 -0600 )edit

Note that "order matters with Catkin" has been discussed on this site quite some times.

To find previous Q&As, I recommend to use Google. Append site:answers.ros.org to your queries.

gvdhoorn gravatar image gvdhoorn  ( 2021-07-23 09:49:08 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2021-07-20 11:10:51 -0600

Seen: 541 times

Last updated: Jul 21 '21