I am attempting to link a ROS project to an external dependency (Gocator SDK or GoSdk) as responsibly as possible. In my current environment (which uses docker), when an external dependency needs to be added, the repo for that dependency is added to a list of external repos (in this case I had to make my own git repo since one didn't already exist), then those repos are compiled as catkin packages, which will finally be fetched by all the various packages in my project as needed. I would like to use the same process for GoSdk, but as I will describe this task would be fairly convoluted.

GoSdk (and an associated dependency, kApi) is compiled by two rather long Makefiles which I would prefer not to touch, so my approach is to run these Makefiles through my CMakeLists.txt file as custom commands, as follows:

cmake_minimum_required(VERSION 3.0.2)
project(GoSdk)

find_package(catkin REQUIRED)

# This is system dependent, it assumes linux_x86d
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/makefiles ) add_custom_target(k_api_build ALL make -f kApi-Linux_X86.mk WORKING_DIRECTORY${CMAKE_CURRENT_SOURCE_DIR}/makefiles
)

catkin_package(LIBRARIES GoSdk)
set_target_properties(GoSdk PROPERTIES IMPORTED_LOCATION \${CMAKE_CURRENT_SOURCE_DIR}/../../build/GoSdk/lib/linux_x86d/libGoSdk.so)


This currently does not work, as when I try to include GoSdk in a find_package(catkin REQUIRED COMPONENTS ... line it gives me the following error:

Project 'foo' tried to find library 'GoSdk'. The library is neither a target nor built/installed properly. Did you compile project 'GoSdk'? Did you find_package() it before the subdirectory containing its code is included?

To recap, I am trying to compile a dependency by calling two Makefiles and then loading the resulting .so file from a CMakeLists.txt file, which will then act as a catkin package, so that I can then find this dependency from my project within its own CMakeLists.txt file using catkin, all so I can use this dependency from my cpp code. This all seems convoluted and not how the pipeline is meant to be used. If you can tell me how to fix my approach it'd be much appreciated!

edit retag close merge delete