The current config file is generating absolute paths in linked dependencies. Use the more modern approach from https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html to generate targets that will use relative dependencies, in particular when installing the package.
This would also fix the problem of having to manually add rtabmap's dependencies explicitly in a downstream projects. For example, those lines:
|
FIND_PACKAGE(OpenCV REQUIRED) |
|
FIND_PACKAGE(PCL 1.7 REQUIRED) |
|
|
|
# Find Qt5 first |
|
FIND_PACKAGE(Qt5 COMPONENTS Widgets Core Gui Svg QUIET) |
|
IF(NOT Qt5_FOUND) |
|
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtSvg) |
|
ENDIF(NOT Qt5_FOUND) |
would not be required anymore as
find_package(RTABMap) will already include those dependencies (include directories and libraries). The target
rtabmap would include everything to build, so the downstream project would need only this in its
CMakeLists.txt file:
find_package(RTABMap REQUIRED)
add_executable(app main.cpp)
target_link_libraries(app rtabmap)
With main.cpp:
#include <rtabmap/corelib/Rtabmap.h>
#include <rtabmap/utilite/ULogger.h>
int main(int argc, char* argv[])
{
UINFO("Launching rtabmap...");
Rtabmap rtabmap;
cv::Mat image;
pcl::PointCloud<pcl::PointXYZ> cloud;
...
}
This would also fix the installation issues in introlab/rtabmap_ros#813
The current config file is generating absolute paths in linked dependencies. Use the more modern approach from https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html to generate targets that will use relative dependencies, in particular when installing the package.
This would also fix the problem of having to manually add rtabmap's dependencies explicitly in a downstream projects. For example, those lines:
rtabmap/examples/RGBDMapping/CMakeLists.txt
Lines 25 to 32 in fa31aff
would not be required anymore as
find_package(RTABMap)will already include those dependencies (include directories and libraries). The targetrtabmapwould include everything to build, so the downstream project would need only this in itsCMakeLists.txtfile:With
main.cpp:This would also fix the installation issues in introlab/rtabmap_ros#813