As CMake's generated targets file does, reset _IMPORT_PREFIX to an empty
string when it resolves to "/".
Reported by @heitbaum in #5587.
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann_jsonTargets.cmake always prepended the prefix computed from the
file's location to includedir. With an absolute includedir outside the
prefix (as Nix passes for packages with a separate dev output), this gave
"<prefix>//abs/include"; with an absolute datadir outside the prefix, the
number of ".." was derived from the absolute path and the prefix resolved
to "/". In both cases find_package(nlohmann_json) failed with "Imported
target includes non-existent path". Use the absolute include directory in
these cases, as CMake's install(EXPORT) does, and check it in CI.
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Finish the Meson changes from #4452:
- Offer all eight options that change the CMake target, named like the
CMake options without the JSON_ prefix. MultipleHeaders defaults to
false so that existing Meson users keep the single header.
- Add a compile definition only for an option that differs from its
default, exactly as target_compile_definitions does. Before, the
GlobalUDLs and ImplicitConversions definitions were inverted and were
also added in the default configuration.
- Keep the nlohmann_json_multiple_headers dependency that earlier
versions of meson.build provided.
- Put the definitions into the pkg-config file and the Meson-generated
nlohmann_jsonTargets.cmake, and install the pkg-config file into
<datadir>/pkgconfig like CMake does.
- Ship meson_options.txt in include.zip, since meson.build now reads
options and the zip is documented as a Meson subproject.
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
A Meson installation only provided the headers and a pkg-config file, so
consumers using find_package(nlohmann_json) could not find the library.
Meson now also installs nlohmann_jsonConfig.cmake and
nlohmann_jsonConfigVersion.cmake from the existing templates, plus a
static nlohmann_jsonTargets.cmake that defines the header-only imported
target with a relocatable include path.
A new CI job installs with Meson and builds tests/cmake_import/project
against the result.
Closes#3885
Signed-off-by: Niels Lohmann <mail@nlohmann.me>