Skip to content

Fix use of vendored json when external is chosen#4782

Open
gdt wants to merge 4 commits into
OSGeo:masterfrom
gdt:fix/misuse-vendored-json
Open

Fix use of vendored json when external is chosen#4782
gdt wants to merge 4 commits into
OSGeo:masterfrom
gdt:fix/misuse-vendored-json

Conversation

@gdt
Copy link
Copy Markdown
Contributor

@gdt gdt commented May 22, 2026

nlohmann/json can either be a normal dependency ("external", the standard approach) or a vendored copy (for those who don't have it installed). There is a header that switches on EXTERNAL_NLOHMANN_JSON to use the system version instead of the vendored version. The build system fails to pass it to some compilations that use json.

This PR, minus the first commit which serves as a test, adds those defines.

An alternative change in the same spirit would be to add the define to all builds, which would be more robust than adding it to builds that use json today. A further change that would improve robustness would be to flip the define to VENDORED_NLOHMANN_JSON and thus if there are new targets that use json with passing it, builds in environments lacking system nlohmann/json will fail, instead of silently using the old code.

It will be interesting to see how CI goes for this branch, which has (temporarily for testing) removed the vendored code. The plan would be to rebase to drop that commit before merging.

@gdt
Copy link
Copy Markdown
Contributor Author

gdt commented May 22, 2026

On my system, with normal-system-dependency nlohmann/json, this branch builds and passes tests as well as master does (one issue in test_network already reported on the list), providing confidence that now all compilations using the json implementation switcher have the flag passed.

gdt added 4 commits May 23, 2026 09:14
The rest of the CI builds use the vendored copy.  For Fedora, install
the external version so that those codepaths will be tested.
This fixes using the outdated vendored copy when external was configured.
Two test programs use json and thus need the define to avoid misusing
the vendored version, when the plan is external.
@gdt gdt force-pushed the fix/misuse-vendored-json branch from 8f28ace to 980e84d Compare May 23, 2026 13:14
@gdt gdt changed the title Fix misused vendored json Fix use of vendored json when external is chosen May 23, 2026
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

Successfully merging this pull request may close these issues.

vendored nlohmann/json is used even if external was chosen

1 participant