"catkin build" OK, "catkin config --install && catkin build" fails

asked 2019-10-31 20:50:34 -0600

KenYN gravatar image

updated 2019-11-05 19:36:07 -0600

Given this CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.11)
project(project_1)

find_package(catkin REQUIRED COMPONENTS
  message_generation
  roslib
  roscpp
  std_msgs
  nodelet
  unique_id
  # Our own header-only modules
  nodelet_helper
  lprof
  pdiag
)

catkin_package(
    INCLUDE_DIRS include
    CATKIN_DEPENDS std_msgs
    LIBRARIES project_1_shared
)

message("Includes: ${catkin_INCLUDE_DIRS}")
# etc...

If I run catkin clean --yes && catkin config --no-install && catkin build project_1, I will see the trace message:

Includes: /builddir/src/Common/CommonLib/lprof/include; /builddir/src/Common/CommonLib/nodelet_helper/include; /builddir/src/Common/CommonLib/panadas_build/include; /builddir/src/Common/CommonLib/pdiag/include; /opt/ros/kinetic/include;/opt/ros/kinetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp;/usr/include

If I now do catkin clean --yes && catkin config --install -i /builddir/catkin-build-install && catkin build -v project_1, I see the following for pdiag (and similarly for lprof and nodelet_helper):

-- Installing: /builddir/catkin-build-install/include/pdiag/include
-- Installing: /builddir/catkin-build-install/include/pdiag/include/pdiag.h

OK! However, for project_1 I get:

Includes: /builddir/catkin-build-install/include; /opt/ros/kinetic/include; /opt/ros/kinetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp;/usr/include

Not surprisingly, the compilation fails with fatal error: pdiag.h: No such file or directory on the first #include "pdiag.h".

Update: pdiag/CMakeLists.txt looks like this; lprof is identical bar project(lprof):

cmake_minimum_required(VERSION 2.8.3)

project(pdiag)

find_package(catkin REQUIRED COMPONENTS roscpp)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS roscpp
  LIBRARIES
  DEPENDS)

install(DIRECTORY include
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

nodelet_helper/CMakeLists.txt has pointless add_library, but that's what we have:

cmake_minimum_required(VERSION 2.8.11)
project(nodelet_helper)

find_package(catkin)

catkin_package(
    INCLUDE_DIRS include
)

add_library(nodelet_helper INTERFACE)
target_sources(nodelet_helper INTERFACE
    include/nodelet_helper/nodelet_helper.h
    include/nodelet_helper/node_main.h
)

install(DIRECTORY include
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)

Why does the install build fail to generate the correct ${catkin_INCLUDE_DIRS}?

edit retag flag offensive close merge delete

Comments

It would help if we could see how you install(..) the headers in pdiag (and lprof and nodelet_helper).

gvdhoorn gravatar image gvdhoorn  ( 2019-11-02 09:06:03 -0600 )edit

@gvdhoorn OK, added the extra CMakeLists.txt.

KenYN gravatar image KenYN  ( 2019-11-05 19:39:31 -0600 )edit