-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Create a jsoncppConfig.cmake file, even if building under meson #1486
Create a jsoncppConfig.cmake file, even if building under meson #1486
Conversation
Not really true, the other project could use
The static library is built by meson if you use the Since this hardcodes .so, it will probably not work on macOS or Windows... it also hardcodes the value of |
That's fair -- i'll do another lap and resubmit |
I have reworked this pr to address your concerns |
meson.build
Outdated
add_library(jsoncpp_lib IMPORTED SHARED) | ||
set_target_properties(jsoncpp_lib PROPERTIES | ||
IMPORTED_LOCATION "${PACKAGE_PREFIX_DIR}/''' + get_option('libdir') + '/' + shared_name + '''" | ||
INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/''' + get_option('includedir') + '")') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest using meson's join_paths('${PACKAGE_PREFIX_DIR}', get_option('XXXdir'), shared_name)
here, since it handles the admittedly unlikely case that libdir or includedir aren't inside the prefix, and also means you can avoid repeatedly entering and then leaving a string literal context.
meson.build
Outdated
|
||
import('cmake').configure_package_config_file( | ||
name: 'jsoncpp', | ||
input: 'jsoncppConfig.cmake.meson.in', | ||
configuration: cmakeconf) | ||
install_data('jsoncpp-namespaced-targets.cmake', install_dir : get_option('libdir') + '/cmake/' + jsoncpp_lib.name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use join_paths here too.
@@ -15,7 +15,7 @@ project( | |||
'cpp_std=c++11', | |||
'warning_level=1'], | |||
license : 'Public Domain', | |||
meson_version : '>= 0.49.0') | |||
meson_version : '>= 0.54.0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fs module is available since 0.53.0, am I overlooking something else that needs 0.54.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure -- when i ran the build meson complained that I should be requiring 0.54.0
I'll do another commit (for the join_paths suggestion, thanks!) and try 0.53.0 then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case it's probably correct -- I haven't checked out the PR and tried it myself -- it should list which feature requires 0.54 though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the 'name' member function was introduced in 0.54.0
WARNING: Project specifies a minimum meson_version '>= 0.53.0' but uses features which were added in newer versions:
* 0.54.0: {'name'}
Ping, this affects some upstream users, can we merge this? |
Currently we have to maintain 2 different code paths since we can't use pkg-config reliably for our Windows builds. We only maintain the pkg-config path to be compliant with package managers that use the meson build instead of the CMake build.
|
@juan-lunarg this is incorrect. pkg-config is not specific to unix. It may or may not be installed on Windows, but that is very different from "totally not available at all". It's e.g. available in vcpkg/conan, and can be manually installed anywhere but would require setting up the prefix paths manually rather than having them be set by default. The "set manually rather than by default" part is, I'm pretty sure, the only reason why Windows users historically don't like it. Well, that and the fact that CMake spreads a lot of untrue FUD about its file format and then refuses to do the simple and obvious thing and e.g. link to libpkgconf to ensure consistency. Please check both, without restricting the situations where you check them. Instead of setting REQUIRED, just do precisely what you do for the cmake config version, and check if the lookup was found and emit |
Update never mind we can use the pkg-config path see: We still support both paths but now we actively test both paths which was my main issue before.
The problem was that the jsoncpp.pc was pointing to the SHARED version of the library instead of the STATIC version which is what we wanted. Disabling the SHARED version fixes the issues for us. |
Thanks, that looks pretty reasonable. :) |
Since cmake files installed under meson too, after open-source-parsers/jsoncpp#1486
If jsoncpp gets built under meson, no cmake package files get created. This means, if another project wants to use jsoncpp, then jsoncpp must have also been built with cmake.
I've created a shim that allows a
jsoncppConfig.cmake
file to be generated under a meson build. I have found this useful when building under buildroot, which uses meson.this file only exposes the jsoncpp_lib target, not the jsoncpp_static one. I don't see a way to build the jsoncpp_static target under meson, but I am much less experienced with meson, so I am very open to suggestion here. the attached patch works for me.