Migrating from catkin_make to catkin build headers

asked 2017-12-04 03:07:07 -0500

danividanivi gravatar image

updated 2017-12-04 05:18:40 -0500

I am following this guide to migrate from catkin_make to catkin build.

catkin_make builds fine, but in the second step, catkin_make_isolated, I have a great number of errors. Checking the troubleshooting section, it seems that my problem is Missing headers.

Let me show you one error example:

In file included from /home/daniel/my_project_ws/src/my_project_ros/EFIS/src/ND/pilotactionlegtf.cpp:8:0:
/home/daniel/my_project_ws/src/my_project_ros/EFIS/src/ND/pilotactionlegtf.h:12:34: fatal error: pilotactiontfmessage.h: No such file or directory
compilation terminated.
EFIS/src/ND/CMakeFiles/nd.dir/build.make:86: recipe for target 'EFIS/src/ND/CMakeFiles/nd.dir/pilotactionlegtf.cpp.o' failed
make[2]: *** [EFIS/src/ND/CMakeFiles/nd.dir/pilotactionlegtf.cpp.o] Error 1
CMakeFiles/Makefile2:2125: recipe for target 'EFIS/src/ND/CMakeFiles/nd.dir/all' failed
make[1]: *** [EFIS/src/ND/CMakeFiles/nd.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
<== Failed to process package 'my_project_ros': 
  Command '['/home/daniel/my_project_ws/devel_isolated/module1/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2 
Command failed, exiting.

If I check pilotactionlegtf.h i have:

#include <pilotactiontfmessage.h>

But for some reason it is unable to find it. I can manually change it to:

#include "../../Messages/pilotactiontfmessage.h"

And then the error dissapears, but the number of these problems is too big for manually changing all the cases. All the headers giving fatal error No such file or directory are under src folder in different folders.

Is there any other solution?

EDIT: I add the CMakeLists.txt in src

# toplevel CMakeLists.txt for a catkin workspace
# catkin/cmake/toplevel.cmake

cmake_minimum_required(VERSION 2.8.3)

set(CATKIN_TOPLEVEL TRUE)

# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
execute_process(COMMAND ${_cmd}
  RESULT_VARIABLE _res
  OUTPUT_VARIABLE _out
  ERROR_VARIABLE _err
  OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_STRIP_TRAILING_WHITESPACE
)
if(NOT _res EQUAL 0 AND NOT _res EQUAL 2)
  # searching fot catkin resulted in an error
  string(REPLACE ";" " " _cmd_str "${_cmd}")
  message(FATAL_ERROR "Search for 'catkin' in workspace failed (${_cmd_str}): ${_err}")
endif()

# include catkin from workspace or via find_package()
if(_res EQUAL 0)
  set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/${_out}/cmake")
  # include all.cmake without add_subdirectory to let it operate in same scope
  include(${catkin_EXTRAS_DIR}/all.cmake NO_POLICY_SCOPE)
  add_subdirectory("${_out}")

else()
  # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
  # or CMAKE_PREFIX_PATH from the environment
  if(NOT DEFINED CMAKE_PREFIX_PATH)
    if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
      string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
    endif()
  endif()

  # list of catkin workspaces
  set(catkin_search_path "")
  foreach(path ${CMAKE_PREFIX_PATH})
    if(EXISTS "${path}/.catkin")
      list(FIND catkin_search_path ${path} _index)
      if(_index EQUAL -1)
        list(APPEND catkin_search_path ${path})
      endif()
    endif()
  endforeach()

  # search for catkin in all workspaces
  set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
  find_package(catkin QUIET
    NO_POLICY_SCOPE
    PATHS ${catkin_search_path}
    NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  unset(CATKIN_TOPLEVEL_FIND_PACKAGE)

  if(NOT catkin_FOUND)
    message(FATAL_ERROR "find_package(catkin) failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was sourced before.")
  endif()
endif()

catkin_workspace()

and the CMakeLists.txt in my_project_ros

project(my_project_ros)
cmake_minimum_required(VERSION 2.8.8)

if ...
(more)
edit retag flag offensive close merge delete

Comments

1

We're going to need to some (an excerpt of) your CMakeLists.txt.

Right now, this reads like a problem with your include paths.

gvdhoorn gravatar imagegvdhoorn ( 2017-12-04 03:32:18 -0500 )edit

or dependencies. Maybe the message headers are just not created yet. I second @gvdhoorn about the CMakeLists.txt.

mgruhler gravatar imagemgruhler ( 2017-12-04 04:08:45 -0500 )edit
1

Msg deps could also be a problem, but #include "../../Messages/pilotactiontfmessage.h" does not look like a proper (auto-generated) msg header to me.

gvdhoorn gravatar imagegvdhoorn ( 2017-12-04 04:10:56 -0500 )edit

I added CmakeLists.txt

danividanivi gravatar imagedanividanivi ( 2017-12-04 05:20:17 -0500 )edit

@gvdhoorn it is not, the .msg files are in a different folder with .msg extension.

danividanivi gravatar imagedanividanivi ( 2017-12-04 05:22:22 -0500 )edit