fix(meson): install CMake package config files#5178
Conversation
Install nlohmann_jsonConfig.cmake, nlohmann_jsonConfigVersion.cmake, and nlohmann_jsonTargets.cmake when building with Meson so consumers can use find_package(nlohmann_json) after a Meson install. Fixes nlohmann#3885
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f0ca894e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if(NOT TARGET nlohmann_json::nlohmann_json) | ||
| get_filename_component( | ||
| _nlohmann_json_include_dir | ||
| "${CMAKE_CURRENT_LIST_DIR}/../../../include" |
There was a problem hiding this comment.
Respect Meson includedir in imported target
The Meson-installed CMake target hard-codes the header location to ${prefix}/include, but Meson can install headers to a different path when --includedir (or an includedir option in packaging) is set. In that case, find_package(nlohmann_json) succeeds yet consumers get an imported target with a wrong INTERFACE_INCLUDE_DIRECTORIES, which breaks includes at compile time. The target path should be generated from the actual Meson includedir instead of a fixed ../../../include assumption.
Useful? React with 👍 / 👎.
|
I am not a Meson expert, and I will not merge an AI-generated patch that I do not understand. Unless somebody else can explain the patch and review it, I will not merge it. |
|
AI slop. |
Summary
nlohmann_jsonConfig.cmake,nlohmann_jsonConfigVersion.cmake, andnlohmann_jsonTargets.cmakewhen building/installing with Meson.cmake/nlohmann_jsonTargets.cmakefor the header-only imported target.find_package(nlohmann_json)expectations.Fixes #3885
Test plan
meson setup build && meson install -C buildplaces*.cmakeundershare/cmake/nlohmann_json/cmake -DCMAKE_PREFIX_PATH=... -DJSON_BuildTests=ONfinds the package (consumer smoke test)Made with Cursor