From 73b8a6a9c88a4de80b37bb54603d5fe56be73960 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 1 Oct 2026 14:16:08 +0200 Subject: [PATCH] Add DisableTupleReferenceConversion to Meson and the CMake pkg-config file JSON_DisableTupleReferenceConversion (#5598) came in with the develop merge. Meson gets the matching option, and both the Meson and the CMake pkg-config file carry JSON_DISABLE_TUPLE_REFERENCE_CONVERSION=1 when it is enabled. The ci_meson_install job checks it. Reported by @heitbaum in #5587. Signed-off-by: Niels Lohmann --- .github/workflows/ubuntu.yml | 5 +++-- CMakeLists.txt | 3 +++ docs/mkdocs/docs/integration/package_managers.md | 4 ++-- meson.build | 3 +++ meson_options.txt | 6 ++++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 68656a43c..3b003b47d 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -51,7 +51,7 @@ jobs: cmake --build build-import - name: Install with Meson and non-default options run: | - meson setup build-meson-options --prefix=${{ github.workspace }}/install-options -DMultipleHeaders=true -DDiagnostics=true -DGlobalUDLs=false + meson setup build-meson-options --prefix=${{ github.workspace }}/install-options -DMultipleHeaders=true -DDiagnostics=true -DGlobalUDLs=false -DDisableTupleReferenceConversion=true meson install -C build-meson-options - name: Check that the options reach the installed files run: | @@ -60,7 +60,8 @@ jobs: echo "$cflags" echo "$cflags" | grep -q -- '-DJSON_DIAGNOSTICS=1' echo "$cflags" | grep -q -- '-DJSON_USE_GLOBAL_UDLS=0' - grep -q 'JSON_USE_GLOBAL_UDLS=0;JSON_DIAGNOSTICS=1' install-options/share/cmake/nlohmann_json/nlohmann_jsonTargets.cmake + echo "$cflags" | grep -q -- '-DJSON_DISABLE_TUPLE_REFERENCE_CONVERSION=1' + grep -q 'JSON_USE_GLOBAL_UDLS=0;JSON_DISABLE_TUPLE_REFERENCE_CONVERSION=1;JSON_DIAGNOSTICS=1' install-options/share/cmake/nlohmann_json/nlohmann_jsonTargets.cmake cmake -S tests/cmake_import/project -B build-import-options -DCMAKE_PREFIX_PATH=${{ github.workspace }}/install-options cmake --build build-import-options - name: Install with Meson and the include directory outside the prefix diff --git a/CMakeLists.txt b/CMakeLists.txt index 5204ff1ed..5c3864359 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,9 @@ endif() if (JSON_DisableEnumSerialization) string(APPEND NLOHMANN_JSON_PKGCONFIG_CFLAGS " -DJSON_DISABLE_ENUM_SERIALIZATION=1") endif() +if (JSON_DisableTupleReferenceConversion) + string(APPEND NLOHMANN_JSON_PKGCONFIG_CFLAGS " -DJSON_DISABLE_TUPLE_REFERENCE_CONVERSION=1") +endif() if (JSON_Diagnostics) string(APPEND NLOHMANN_JSON_PKGCONFIG_CFLAGS " -DJSON_DIAGNOSTICS=1") endif() diff --git a/docs/mkdocs/docs/integration/package_managers.md b/docs/mkdocs/docs/integration/package_managers.md index b63adee76..a1b67c908 100644 --- a/docs/mkdocs/docs/integration/package_managers.md +++ b/docs/mkdocs/docs/integration/package_managers.md @@ -128,8 +128,8 @@ subproject fallback, rather than using the subproject directly. The options that change the library's configuration are available in Meson as well, named like the [CMake options](cmake.md#cmake-options) without the `JSON_` prefix: `MultipleHeaders`, `GlobalUDLs`, -`ImplicitConversions`, `DisableEnumSerialization`, `Diagnostics`, `Diagnostic_Positions`, -`LegacyDiscardedValueComparison`, and `StrictNulHandling`. They have the same defaults as in CMake, except that +`ImplicitConversions`, `DisableEnumSerialization`, `DisableTupleReferenceConversion`, `Diagnostics`, +`Diagnostic_Positions`, `LegacyDiscardedValueComparison`, and `StrictNulHandling`. They have the same defaults as in CMake, except that `MultipleHeaders` is `false`. Set them with `-D` when setting up the build, or with the subproject name as prefix when the library is used as a subproject: diff --git a/meson.build b/meson.build index 33b2ff466..2ece2ab42 100644 --- a/meson.build +++ b/meson.build @@ -24,6 +24,9 @@ endif if get_option('DisableEnumSerialization') json_defines += 'JSON_DISABLE_ENUM_SERIALIZATION=1' endif +if get_option('DisableTupleReferenceConversion') + json_defines += 'JSON_DISABLE_TUPLE_REFERENCE_CONVERSION=1' +endif if get_option('Diagnostics') json_defines += 'JSON_DIAGNOSTICS=1' endif diff --git a/meson_options.txt b/meson_options.txt index ebb19bb40..5f38c5105 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -22,6 +22,12 @@ option( value: false, description: 'Disable default integer enum serialization', ) +option( + 'DisableTupleReferenceConversion', + type: 'boolean', + value: false, + description: 'Disable conversion from a one-element tuple of a JSON reference', +) option( 'Diagnostics', type: 'boolean',