Skip to content

fix(meson): install CMake package config files#5178

Closed
leno23 wants to merge 1 commit into
nlohmann:developfrom
leno23:fix/meson-install-cmake-config-3885
Closed

fix(meson): install CMake package config files#5178
leno23 wants to merge 1 commit into
nlohmann:developfrom
leno23:fix/meson-install-cmake-config-3885

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

  • Install nlohmann_jsonConfig.cmake, nlohmann_jsonConfigVersion.cmake, and nlohmann_jsonTargets.cmake when building/installing with Meson.
  • Add a static cmake/nlohmann_jsonTargets.cmake for the header-only imported target.
  • Align Meson installs with CMake find_package(nlohmann_json) expectations.

Fixes #3885

Test plan

  • meson setup build && meson install -C build places *.cmake under share/cmake/nlohmann_json/
  • cmake -DCMAKE_PREFIX_PATH=... -DJSON_BuildTests=ON finds the package (consumer smoke test)

Made with Cursor

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
@leno23 leno23 requested a review from nlohmann as a code owner May 17, 2026 15:52
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@nlohmann
Copy link
Copy Markdown
Owner

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.

@nlohmann nlohmann added the review needed It would be great if someone could review the proposed changes. label May 17, 2026
@nlohmann
Copy link
Copy Markdown
Owner

AI slop.

@nlohmann nlohmann closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake M review needed It would be great if someone could review the proposed changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

meson build does not install nlohmann_json*.cmake files

2 participants