Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor RTABMapConfig.cmake to use targets #903

Closed
matlabbe opened this issue Sep 25, 2022 · 0 comments · Fixed by #904
Closed

Refactor RTABMapConfig.cmake to use targets #903

matlabbe opened this issue Sep 25, 2022 · 0 comments · Fixed by #904

Comments

@matlabbe
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant