Skip to content
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

includedir in pkgconfig is error if install_headers() has subdir argument. #3284

Closed
hlqqlm opened this issue Jan 21, 2022 · 5 comments
Closed

Comments

@hlqqlm
Copy link

hlqqlm commented Jan 21, 2022

meson.build has below code:
install_headers('single_include/nlohmann/json.hpp', subdir: 'nlohmann')
It install header file into subdir, such as
~/.local/nlohmann

but pkgconfig file nlohmann_json.pc has below code:
includedir=${prefix}/include
It should be:
includedir=${prefix}/include/nlohmann

You can fix this bug by installing header without subdir:
install_headers('single_include/nlohmann/json.hpp')
Otherwise you can change pkgconfig file nlohmann_json.pc, but I don't know how to do that.

@nlohmann
Copy link
Owner

Is this related to #3248?

@eli-schwartz
Copy link
Contributor

This seems to be incorrect, because as per the documentation at https://github.com/nlohmann/json#integration you should be using:

#include <nlohmann/json.hpp>

and as such, it is correct to install it to an "nlohmann/" subdirectory but not add that to the include paths.

Conversely, you appear to instead be using:

#include <json.hpp>

Which is a bad idea for several reasons -- scoping, particularly, because it's hardly as though "json.hpp" is an uncommon header name. And indeed, if you use this then it will not be found in ${prefix}/include.

If you use the cmake config files instead of the pkg-config files, you will still get ${prefix}/include, not ${prefix}/include/nlohmann/, so it is not a pkg-config issue either. Nor is it anything to do with meson, because cmake also installs a pkg-config file, and that pkg-config file points to the same path (${prefix}/include) that meson's generated pkg-config file uses.

@gregmarr
Copy link
Contributor

@eli-schwartz is correct. It is expected that nlohmann/ be part of your #include. It doesn't make a lot of difference if you install the single include header and decide to put nlohmann in your include path and do the include without it, but it's mandatory that you use the expected form if you use the multiple headers, as they include each other using the #include <nlohmann/...> form. For that reason, it's best to always include it with the nlohmann/ prefix and have the nlohmann directory inside a directory in your include path.

@nlohmann
Copy link
Owner

Anything to do here?

@hlqqlm
Copy link
Author

hlqqlm commented Jan 24, 2022

@eli-schwartz is correct. We should code as below:
#include <nlohmann/json.hpp>
@nlohmann This is a wrong bug issue, I have closed it.

@hlqqlm hlqqlm closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants