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

Adding header files from specific folder to library using catkin_simple

asked 2020-01-18 08:39:38 -0500

prex gravatar image

updated 2020-01-20 07:08:53 -0500

I'm trying to create a catkin wrapper to build a library from external files. I'm usually using catkin_simple. However, the header files here are not contained in the include directory. I'm trying to figure out where to install them so that I can use #include <AdsLib/AdsLib.h> in other catkin packages to use this library.

Looking at catkin_simple's cs_install macro, I tried to add my header files. However, other packages can still not find the includes.

Edit: The files exist in install/include. But it seems like the build system is looking for them in the devel or source space. Since catkin_simple is only including from the include folder, I tried to add catkin_package(INCLUDE_DIRS ${SOURCE_DIR}/AdsLib). But the command is executed before the external project folder is cloned, which leads to an error.

What am I missing?

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(ads_catkin)

find_package(catkin_simple REQUIRED)
catkin_simple()

include(ExternalProject)


ExternalProject_Add(ads
    PREFIX ${CATKIN_DEVEL_PREFIX}/ads
    GIT_REPOSITORY https://github.com/Beckhoff/ADS.git
    GIT_TAG 6b3a03009a757cf651fe44d8be7b6df698028f0e
    #GIT_TAG master
    CONFIGURE_COMMAND ""
    UPDATE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
    BUILD_BYPRODUCTS 
        <SOURCE_DIR>/AdsLib/AdsDef.cpp
        <SOURCE_DIR>/AdsLib/AdsLib.cpp
        <SOURCE_DIR>/AdsLib/AmsConnection.cpp
        <SOURCE_DIR>/AdsLib/AmsPort.cpp
        <SOURCE_DIR>/AdsLib/AmsRouter.cpp
        <SOURCE_DIR>/AdsLib/Frame.cpp
        <SOURCE_DIR>/AdsLib/Log.cpp
        <SOURCE_DIR>/AdsLib/NotificationDispatcher.cpp
        <SOURCE_DIR>/AdsLib/Sockets.cpp
        <SOURCE_DIR>/AdsLib/AdsDef.h
        <SOURCE_DIR>/AdsLib/AdsLib.h
        <SOURCE_DIR>/AdsLib/AdsNotification.h
        <SOURCE_DIR>/AdsLib/AmsConnection.h
        <SOURCE_DIR>/AdsLib/AmsHeader.h
        <SOURCE_DIR>/AdsLib/AmsPort.h
        <SOURCE_DIR>/AdsLib/AmsRouter.h
        <SOURCE_DIR>/AdsLib/Frame.h
        <SOURCE_DIR>/AdsLib/Log.h
        <SOURCE_DIR>/AdsLib/NotificationDispatcher.h
        <SOURCE_DIR>/AdsLib/RingBuffer.h
        <SOURCE_DIR>/AdsLib/Router.h
        <SOURCE_DIR>/AdsLib/Semaphore.h
        <SOURCE_DIR>/AdsLib/Sockets.h
        <SOURCE_DIR>/AdsLib/wrap_endian.h
        <SOURCE_DIR>/AdsLib/wrap_socket.h
)

ExternalProject_Get_Property(ads SOURCE_DIR)


include_directories(
    ${SOURCE_DIR}
)

cs_add_library(AdsLib
    ${SOURCE_DIR}/AdsLib/AdsDef.cpp
    ${SOURCE_DIR}/AdsLib/AdsLib.cpp
    ${SOURCE_DIR}/AdsLib/AmsConnection.cpp
    ${SOURCE_DIR}/AdsLib/AmsPort.cpp
    ${SOURCE_DIR}/AdsLib/AmsRouter.cpp
    ${SOURCE_DIR}/AdsLib/Frame.cpp
    ${SOURCE_DIR}/AdsLib/Log.cpp
    ${SOURCE_DIR}/AdsLib/NotificationDispatcher.cpp
    ${SOURCE_DIR}/AdsLib/Sockets.cpp
)
add_dependencies(AdsLib ads)


cs_install()

install(DIRECTORY ${SOURCE_DIR}/
        DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
        FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"  
)

cs_export(
    INCLUDE_DIRS ${SOURCE_DIR}/AdsLib
)

And the error:

In file included from /home/xxx/xxx/src/xxx/nav_controller/src/controller.cpp:19:0:
/home/xxx/xxx/src/Navion/nav_controller/include/nav_controller/controller.h:27:10: fatal error: AdsLib/AdsLib.h: No such file or directory
 #include <AdsLib/AdsLib.h>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-01-22 12:05:43 -0500

prex gravatar image

I switched to the DownloadProject Cmake module, which works perfectly fine now: https://github.com/Crascit/DownloadPr...

The problem was that the steps from cs_export were executed before the source code was downloaded.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-01-18 08:39:38 -0500

Seen: 603 times

Last updated: Jan 22 '20