Skip to content

CMake: generate a pkg-config file that follow pkg-config conventions #4456

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 2 commits into from
Nov 26, 2024

Conversation

dcbaker
Copy link
Contributor

@dcbaker dcbaker commented Sep 11, 2024

The pkg-config file generated by Meson matches the convention of using a prefix variable, and an includedir variable that is relative to prefix (includedir=${prefix}/include). The one generated by CMake does not do this, but hard codes the include directory straight into the Cflags field. There are advantages to having the prefix (thus the convention)`, especially when cross compiling.

This PR makes the CMake generated pkg-config file meat convention, and match the one generated by Meson.

Pull request checklist

Read the Contribution Guidelines for detailed information.

  • Changes are described in the pull request, or an existing issue is referenced.
  • The test suite compiles and runs without error.
  • Code coverage](https://coveralls.io/github/nlohmann/json) is 100%. Test cases can be added by editing the test suite.
  • The source code is amalgamated; that is, after making changes to the sources in the include/nlohmann directory, run make amalgamate to create the single-header files single_include/nlohmann/json.hpp and single_include/nlohmann/json_fwd.hpp. The whole process is described here.

And use @ replacement instead of {}, since ${} is significant in
pkg-config's format
This is more standard, and has some advantages when cross compiling.
This also means that the pkg-config files generated by Meson and CMake
now match.
Copy link
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@nlohmann nlohmann added this to the Release 3.11.4 milestone Nov 26, 2024
@nlohmann nlohmann merged commit d333f08 into nlohmann:develop Nov 26, 2024
4 checks passed
@nlohmann
Copy link
Owner

Thanks!

@dcbaker dcbaker deleted the submit/pkg-config-updates branch November 26, 2024 17:54
slowriot pushed a commit to slowriot/json that referenced this pull request Jan 10, 2025
…lohmann#4456)

* CMake: configure pkg-config with @only

And use @ replacement instead of {}, since ${} is significant in
pkg-config's format

* CMake: use conventional prefix and incluedir variables in pkg-config

This is more standard, and has some advantages when cross compiling.
This also means that the pkg-config files generated by Meson and CMake
now match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants