Skip to content

Find nlohmann_json test dependency only when required #342

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

Merged
merged 4 commits into from
Apr 20, 2024

Conversation

justend29
Copy link
Contributor

nlohmann::json is used in the examples and tests of jwt-cpp. However, it was always found, making it a transitive dependency for all users of jwt-cpp - even those not building examples or tests. These changes simply check if nlohman_json is required as a host dependency before searching for it.

Copy link
Owner

@Thalhammer Thalhammer left a comment

Choose a reason for hiding this comment

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

If @justend29 wants to extend it with cmake_dependent_option I am open to it, otherwise its good to merge as is.

@justend29
Copy link
Contributor Author

justend29 commented Apr 18, 2024

@prince-chrismc @Thalhammer

Yes - I believe falling back to downloading and building the package when it's not found is not a convenience, it's a mistake. It's far too easy to mistype paths and then get the surprise of downloading a package you already have. Explicit selection of which to use is worthwhile.

A dependent option, maybe JWT_EXTERNAL_TEST_NLOHMANN_JSON, would offer this control. Additionally, CMake has built-in integration between find_package and fetch_content offered in CMake 3.24+ allowing standard CMake variables control how the dependencies are acquired, and dependency providers can be used to override it. Nevertheless, this project only mandates CMake 3.14+, and CMake 3.24's integrations would only complement JWT's variable for users who use compatible versions.

Adding now. Let me know if you'd like further changes.

Also, really great library. Thank you for the contributions.

justend29 and others added 3 commits April 18, 2024 17:06
I think in the longer term we'll probably switch to this since it;s maintained unlike the current default
@prince-chrismc
Copy link
Collaborator

  • none of these options are used by the package managers so 👍
  • the cmake installed config does not check for nlohmann
  • the cmake tests use the internal find_package module for picojson

LGTM, thanks for the contribution.

I think there are missing tests for and/or feature for pickup the different JSON libraries from out find config but thats also not how it's supported? it just adds all of them and lets the user figure the rest out 🤷

@prince-chrismc prince-chrismc merged commit d53e013 into Thalhammer:master Apr 20, 2024
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants