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

Structure Cmake for Cpp package managers #1391

Closed
bazfp opened this issue Mar 31, 2021 · 9 comments
Closed

Structure Cmake for Cpp package managers #1391

bazfp opened this issue Mar 31, 2021 · 9 comments

Comments

@bazfp
Copy link
Collaborator

bazfp commented Mar 31, 2021

It would be useful to be able to use MAVSDK with cpp package managers (Hunter, Conan etc) for automatic dependency resolution. Instead of depending on a SUPERBUILD or local dependencies.

I've been implementing this library with hunter and have found success by doing the following:

  1. SUPERBUILD=OFF
  2. Remove git commands from Cmakelists.txt, such as getting version from git tags
  3. Don't use git submodules
  4. Remove Find modules provided by https://github.com/mavlink/MAVSDK/blob/main/src/cmake/Modules/
  5. Use common lib names when linking:
    JsonCpp::jsoncpp -> jsoncpp_lib
    tinyxml2::tinyxml2 -> tinyxml2

This won't work for mavsdk_server but it is a start. There is likely to be more changes to this to get it to work (for Hunter I have included Hunter_gate but obviously this differs for each manager :) )

@JonasVautherin
Copy link
Collaborator

How did you update Findtinyxml2.cmake? Does it still work for the other cases?

@bazfp
Copy link
Collaborator Author

bazfp commented Mar 31, 2021

I removed lines 18-23.

It is unlikely to work in other cases - that why I have not submitted a PR.

@JonasVautherin
Copy link
Collaborator

But why doesn't find_package(TINYXML2) work in the first place? Isn't the package manager (e.g. hunter) supposed to work with it? Like by setting some CMAKE_PREFIX_PATH or something?

We use pkgconfig as a fallback already...

@bazfp
Copy link
Collaborator Author

bazfp commented Apr 1, 2021

Yes you're correct. It was not working due to the aliased lib names in the provided Find cmake modules. I no longer use the provided src/cmake/Modules/Find* modules now and lean on the package manager for finding packages. I have had to rename the libs that were linked as they were incorrect.

Jsoncpp::jsoncpp -> jsoncpp_lib
tinyxml2::tinyxml2 -> tinyxml2

@JonasVautherin
Copy link
Collaborator

FYI, I believe it should be fixed for jsoncpp using #1395. It's not a release yet, so I don't really know how it goes with Hunter, but I think jsoncpp now has the behavior you expect.

@bazfp
Copy link
Collaborator Author

bazfp commented May 14, 2021

Aha, Good news :)

I will wait for fresh jsoncpp & tinyxml2 releases with the namespaced library names, and push them to hunter.

Once this is all done I will update the PR #1393, it should be a relatively light-touch hunter integration at that point :)

@JonasVautherin
Copy link
Collaborator

@bazfp: Updated tinyxml2 here: #1436

@bazfp
Copy link
Collaborator Author

bazfp commented Oct 29, 2021

Progressing hunter to include MAVSDK as a lib, I have noticed the build fails due to missing submodules in sources.tar.gz. It does not have .git info and so it is impossible fetch submodules from this.

I think the solution here is to put the mavlink headers into hunter, and on HUNTER_ENABLED=ON use hunter instead of the submodules.

@julianoes
Copy link
Collaborator

@bazfp added hunter support.

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