I’m running out of ideas how to fix this. I have a CMakeList used by the catkin_tools (ROS) build system. Furthermore, I’m using catkin_simple, which defines some macros. However, the problem I have is more related to the ExternalProjects_Add function, which I use to get my files from Github to add them as a library.
Having local files in a source folder with an include folder, everything went as expected. When I started downloading them directly from Github, I had the problem that the headers can not be found, because they are not in the source include folder as before. I added cs_export(INCLUDE_DIRS ${SOURCE_DIR}/AdsLib)
which now tries to find the folder before the folders are even cloned.
This is my file which does not work:
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
CONFIGURE_COMMAND ""
UPDATE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
BUILD_BYPRODUCTS
<SOURCE_DIR>/AdsLib/AdsDef.cpp
<SOURCE_DIR>/AdsLib/AdsLib.cpp
...
<SOURCE_DIR>/AdsLib/AdsDef.h
<SOURCE_DIR>/AdsLib/AdsLib.h
...
)
ExternalProject_Get_Property(ads SOURCE_DIR)
include_directories(
${SOURCE_DIR}/AdsLib
)
cs_add_library(AdsLib
${SOURCE_DIR}/AdsLib/AdsDef.cpp
${SOURCE_DIR}/AdsLib/AdsLib.cpp
...
)
add_dependencies(AdsLib ads)
cs_install()
install(DIRECTORY ${SOURCE_DIR}/AdsLib/
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)
cs_export(
INCLUDE_DIRS ${SOURCE_DIR}/AdsLib
)
As a comparison, here is a file that works perfectly fine with local files:
cmake_minimum_required(VERSION 2.8.3)
project(ads_twincat)
find_package(catkin_simple REQUIRED)
catkin_simple()
add_definitions(-std=c++11 -Wall -Wextra)
cs_add_library(${PROJECT_NAME}
src/AdsDef.cpp
src/AdsLib.cpp
...
)
cs_install()
cs_export()