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

Add utility functions to convert to/from JSON #10

Merged
merged 3 commits into from
Jan 25, 2023
Merged

Conversation

luator
Copy link
Member

@luator luator commented Jan 23, 2023

Description

Simple functions that wrap the code for converting an object to/from a JSON string (or stream) using cereal.

They were implemented in vicon_transformer originally, but since they are very generic, I think it makes more sense to have them here.

This PR also fixes an issue in the CMake config: Optional dependencies should use find_package and not find_dependency in the Config.cmake.in. Further, the REQUIRED keyword should not be used there.

This file contains templated utility functions to (de-)serialize an
object from/to JSON strings using cereal.
Only required dependencies should use `find_dependency` (and _not_ have
the REQUIRED keyword), while for optional dependencies one should stick
to `find_package`.
See https://stackoverflow.com/a/64847834/2095383

This fixes a build error if a package depends on serialization_utils but
OpenCV is not available.
@luator luator added the enhancement New feature or request label Jan 23, 2023
@luator luator requested a review from vincentberenz January 23, 2023 14:18
@luator luator self-assigned this Jan 23, 2023

# optional dep
find_dependency(OpenCV QUIET)
find_package(OpenCV QUIET)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my education: what is the difference ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It forwards the REQUIRED or QUIET parameters of the original find_package call (i.e. find_package(serialization_utils ...)). I think the reasoning is that if serialization_utils itself is only required as optional dependency, it should not fail the build if one of its dependencies is not there.
On the other hand, this means that if serialization_utils is required, all the find_dependency calls automatically become required too (to my understanding the QUIET parameter was simply ignored here), which is not desired for optional dependencies.
See https://stackoverflow.com/a/64847834/2095383

@luator luator merged commit ea76c9d into master Jan 25, 2023
@luator luator deleted the fwidmaier/json_utils branch January 25, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants