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

Link a library from other package #30

Open
zephyrdaddy opened this issue Sep 19, 2022 · 4 comments
Open

Link a library from other package #30

zephyrdaddy opened this issue Sep 19, 2022 · 4 comments

Comments

@zephyrdaddy
Copy link

I am trying to link a library from other ros package to a ros package. I understand that the mrt_cmake_modules should make these entire dependency linkage process smooth and easy, but I am having some trouble linking a library to my package.

I am working on the LIMO SLAM package (link) which rely on the mrt_cmake_modules to generate the dependencies.

In the LIMO SLAM project, different ros packages from other git repos are used and linked.
With the dependencies auto-generated, the launch file can instantiate other package's module. However, what I need is more than this.

I need my main program (also auto-generated through mrt_cmake_modules) to include the headers from other packages. The main program is demo_keyframe_bundle_adjustment_meta/apps/main_program.cpp in my repo. I want it to be able to include the header from an external package called image_preprocessing_tool.

I organized the package structure of the image_preprocessing_tool to be compatible with mrt_cmake_modules guide. I was expecting the mrt_cmake_modules to auto-generate the linkage by putting this package name to my main package, but sadly it does not seem working.

I noticed that the cmake macro MRT_INCLUDE_DIR and the MRT_LIBRARIES seem to be empty which I suppose should contain the paths for the dependent packages. When I added hard coded paths into the cmakelist file, the code worked.

I don't know if I conveyed my problem clearly.

I wasn't sure how to use the mrt_cmake_modules properly for this task.

I would appreciate any help.
Thank you for your help in advance.

@johannes-graeter
Copy link

@poggenhans could you help with that, would be greatly appreciated (and repayed in coffee :) )

@johannes-graeter
Copy link

@poggenhans ping

@poggenhans
Copy link
Contributor

Well it's a bit hard to figure out whats wrong without any code or minimal example. From the description of your problem my wild guess is that since image_preprocesing_tool is a tool, it doesn't generate a library and thus exports no library targets for CMake. Otherwise your approach sounds correct to me.

Regarding the MRT_LIBRARIES variable and others, it might be that the documentation on this is a bit outdated. I think this variable is no longer used because of the obvious downsides of using a global variable. Instead, an interface library target named <mypackage>::auto_deps is created which in turn depends on all targets specified in package.xml and this is automatically linked when using mrt_add_library or mrt_add_executable.

@zephyrdaddy
Copy link
Author

@poggenhans @johannes-graeter Thanks very much for the help! I will do the following.

  1. Make a minimal example that represents my need

  2. Check the difference btw normal packages and the "tools" packages.

  3. Check the interface library target <mypackage>::auto_deps

Thanks a lot!

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

No branches or pull requests

3 participants