jsoncpp icon indicating copy to clipboard operation
jsoncpp copied to clipboard

meson and cmake install different sets of files

Open yurivict opened this issue 4 years ago • 4 comments

meson installs:

include/json/allocator.h
include/json/assertions.h
include/json/config.h
include/json/forwards.h
include/json/json.h
include/json/json_features.h
include/json/reader.h
include/json/value.h
include/json/version.h
include/json/writer.h
lib/libjsoncpp.a
lib/libjsoncpp.so
lib/libjsoncpp.so.24
libdata/pkgconfig/jsoncpp.pc

cmake installs:

nclude/json/allocator.h
include/json/assertions.h
include/json/config.h
include/json/forwards.h
include/json/json.h
include/json/json_features.h
include/json/reader.h
include/json/value.h
include/json/version.h
include/json/writer.h
lib/cmake/jsoncpp/jsoncppConfig-%%CMAKE_BUILD_TYPE%%.cmake
lib/cmake/jsoncpp/jsoncppConfig.cmake
lib/cmake/jsoncpp/jsoncppConfigVersion.cmake
lib/libjsoncpp.so
lib/libjsoncpp.so.1.9.4
lib/libjsoncpp.so.24
lib/libjsoncpp_static.a
lib/objects-Release/jsoncpp_object/json_reader.cpp.o
lib/objects-Release/jsoncpp_object/json_value.cpp.o
lib/objects-Release/jsoncpp_object/json_writer.cpp.o
libdata/pkgconfig/jsoncpp.pc

Since cmake itself requires jsoncpp we have to use meson to build jsoncpp. However, some other projects, ex. Microdoft's APSI (https://github.com/microsoft/APSI) look for jsoncpp through cmake files.

Lists of files that cmake and meson install should be identical.

yurivict avatar May 06 '21 08:05 yurivict

+1 on this. When built with Meson, jsoncpp is not detected anymore with cmake find_package because the config files are not installed

adorostkar avatar Jun 13 '22 14:06 adorostkar

Is there any way to create a -targets.cmake file other than by buildsystem lock-in of "use cmake"? Presumably one would have to write it by hand, but that seems... complicated, as is the cmake programming language it's written in. :)

Regardless of build system, a pkg-config file is installed, it's a simple key/value format anyone can write by hand, and Meson can autogenerate. It's also a standard published by an interoperability group, predates cmake find_package and may predate cmake too, and works everywhere that find_package works (yes, this includes Windows), but also in build systems other than cmake. :)

What is the downside of using cmake's pkg_check_modules(JSONCPP IMPORTED_TARGET GLOBAL jsoncpp)?

If it's very important to avoid using cmake's pkg-config support, would you like to volunteer to write a jsoncpp-targets.cmake file that can be checked into git and copied into the install tree? If so, Meson can install the rest as well:

  • cmake.configure_package_config_file() -> can configure and install jsoncppConfig.cmake.in
  • cmake.write_basic_package_version_file() -> requires cmake to be installed (??? !!!), but configures the Modules/BasicConfigVersion-*.cmake.in file from a cmake installation into a version file

Without a handwritten targets file I'm not sure there's much to discuss here.

eli-schwartz avatar Jun 13 '22 22:06 eli-schwartz

For those who use embedded systems pkg_check_modules is not available for older versions of cmake like version 3.13.4.

cronnosli avatar Jan 17 '23 18:01 cronnosli

Which is terrible and unfortunate and a real flaw in older versions of cmake, so I do understand the pain of not being able to use it.

But on the other hand, on the rare occasion that I touch cmake and also have to support ancient versions, I just vendored FindPkgConfig.cmake from the latest version of cmake. It works and provides the needed functionality, fortunately.

eli-schwartz avatar Jan 17 '23 18:01 eli-schwartz