From b242c0bc30f55b2cfc3e133333a95a4b189f7c32 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 6 Oct 2026 07:26:59 +0200 Subject: [PATCH] Fix the standalone release tarball; update compiler list and CITATION Squashed onto develop from: - Make the json.tar.xz release archive configure standalone - Update the supported compiler list and the CITATION.cff repository link - Add json_fwd.hpp to the Bazel singleheader-json target - Document SwiftPM's #include form and add CI coverage - Migrate REUSE metadata from deprecated .reuse/dep5 to REUSE.toml Signed-off-by: Niels Lohmann --- .github/workflows/macos.yml | 35 +++++++++++++++ .reuse/dep5 | 36 --------------- BUILD.bazel | 1 + CITATION.cff | 2 +- CMakeLists.txt | 5 ++- FILES.md | 6 +-- Makefile | 7 ++- Package.swift | 2 +- README.md | 23 +++++----- REUSE.toml | 52 ++++++++++++++++++++++ cmake/scripts/gen_bazel_build_file.cmake | 1 + cmake/scripts/gen_hedley_undef_check.cmake | 2 +- docs/mkdocs/docs/integration/cmake.md | 2 +- 13 files changed, 118 insertions(+), 56 deletions(-) delete mode 100644 .reuse/dep5 create mode 100644 REUSE.toml diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 0adaf26d5..e63a034c6 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -71,3 +71,38 @@ jobs: run: cmake --build build --parallel 10 - name: Test run: cd build ; ctest -j 10 --output-on-failure + + swiftpm: + runs-on: macos-15 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Check that Package.swift resolves without a deprecation warning + run: swift package dump-package + - name: Build the SwiftPM documentation example against this checkout + run: | + mkdir -p /tmp/json-swiftpm-consumer/Sources/MyLibrary + cp docs/mkdocs/docs/integration/swift/example.cpp /tmp/json-swiftpm-consumer/Sources/MyLibrary/example.cpp + cat > /tmp/json-swiftpm-consumer/Package.swift << EOF + // swift-tools-version: 5.9 + import PackageDescription + + let package = Package( + name: "MyPackage", + dependencies: [ + .package(path: "${{ github.workspace }}") + ], + targets: [ + .target( + name: "MyLibrary", + dependencies: [ + .product(name: "json", package: "json") + ], + publicHeadersPath: "." + ) + ] + ) + EOF + cd /tmp/json-swiftpm-consumer + swift build diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index d12cb816c..000000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,36 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: json -Upstream-Contact: Niels Lohmann -Source: https://github.com/nlohmann/json - -Files: * -Copyright: 2013-2026 Niels Lohmann -License: MIT - -Files: include/nlohmann/thirdparty/hedley.hpp -Copyright: 2016-2021 Evan Nemerson -License: CC0 - -Files: include/nlohmann/detail/meta/cpp_future.hpp -Copyright: 2013-2026 Niels Lohmann and 2018 The Abseil Authors -License: MIT AND Apache-2.0 - -Files: tests/thirdparty/doctest/* -Copyright: 2016-2023 Viktor Kirilov -License: MIT - -Files: tests/thirdparty/fifo_map/* -Copyright: 2015-2017 Niels Lohmann -License: MIT - -Files: tests/thirdparty/imapdl/* -Copyright: 2017 Georg Sauthoff -License: GPL-3.0-only - -Files: tools/amalgamate/* -Copyright: 2012 Erik Edlund -License: BSD-3-Clause - -Files: tools/gdb_pretty_printer/* -Copyright: 2020 Hannes Domani -License: MIT diff --git a/BUILD.bazel b/BUILD.bazel index 3dfffad1e..268c3e959 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -80,6 +80,7 @@ cc_library( name = "singleheader-json", hdrs = [ "single_include/nlohmann/json.hpp", + "single_include/nlohmann/json_fwd.hpp", ], includes = ["single_include"], visibility = ["//visibility:public"], diff --git a/CITATION.cff b/CITATION.cff index 8a70c17bc..eb5118999 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -10,5 +10,5 @@ title: "JSON for Modern C++" version: 3.12.0 date-released: 2025-04-07 license: MIT -repository-code: "https://github.com/nlohmann" +repository-code: "https://github.com/nlohmann/json" url: https://json.nlohmann.me diff --git a/CMakeLists.txt b/CMakeLists.txt index a2501a92d..fed9e3171 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,8 +42,11 @@ endif() ## OPTIONS ## +# Build the tests by default only for the main project and only if the tests +# directory exists (the release archive json.tar.xz does not contain it). # VERSION_GREATER_EQUAL is not available in older CMake (< 3.7) -if(${MAIN_PROJECT} AND (${CMAKE_VERSION} VERSION_EQUAL 3.13 OR ${CMAKE_VERSION} VERSION_GREATER 3.13)) +if(${MAIN_PROJECT} AND (${CMAKE_VERSION} VERSION_EQUAL 3.13 OR ${CMAKE_VERSION} VERSION_GREATER 3.13) + AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt") set(JSON_BuildTests_INIT ON) else() set(JSON_BuildTests_INIT OFF) diff --git a/FILES.md b/FILES.md index d13be1238..861fdf610 100644 --- a/FILES.md +++ b/FILES.md @@ -196,19 +196,19 @@ Further documentation: ## REUSE -### `.reuse/dep5` +### `REUSE.toml` The file defines the licenses of certain third-party components in the repository. The root `Makefile` contains a target `reuse` that checks for compliance. Further documentation: -- [DEP5](https://reuse.software/spec-3.2/#dep5-deprecated) +- [REUSE.toml](https://reuse.software/spec-3.3/#reusetoml) - [reuse command-line tool](https://pypi.org/project/reuse/) - [documentation of linting](https://reuse.readthedocs.io/en/stable/man/reuse-lint.html) - [REUSE](http://reuse.software) > [!IMPORTANT] -> The filename `.reuse/dep5` is predetermined by REUSE. Alternatively, a `REUSE.toml` file can be used. +> The filename `REUSE.toml` is predetermined by REUSE. Alternatively, a `.reuse/dep5` file (deprecated) can be used. ### `.reuse/templates` diff --git a/Makefile b/Makefile index 3a7fa5c41..11b9227a4 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ # find GNU sed to use `-i` parameter SED:=$(shell command -v gsed || which sed) +# find GNU tar to use `--sort` and `--pax-option` parameters +TAR:=$(shell command -v gtar || which tar) + ########################################################################## # source files @@ -174,8 +177,8 @@ ChangeLog.md: # archive is created according to the advices of . json.tar.xz: mkdir json - rsync -R $(shell find LICENSE.MIT nlohmann_json.natvis CMakeLists.txt cmake/*.in include single_include -type f) json - gtar --sort=name --mtime="@$(shell git log -1 --pretty=%ct)" --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime --create --file - json | xz --compress -9e --threads=2 - > json.tar.xz + rsync -R $(shell find LICENSE.MIT nlohmann_json.natvis CMakeLists.txt cmake/*.in include single_include src/modules -type f) json + $(TAR) --sort=name --mtime="@$(shell git log -1 --pretty=%ct)" --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime --create --file - json | xz --compress -9e --threads=2 - > json.tar.xz rm -fr json # We use `-X` to make the resulting ZIP file reproducible, see diff --git a/Package.swift b/Package.swift index 2f1e654a2..09b12dea3 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "nlohmann-json", platforms: [ - .iOS(.v12), .macOS(.v10_13), .tvOS(.v12), .watchOS(.v4), .visionOS(.v1) + .iOS(.v12), .macOS(.v10_13), .tvOS(.v12), .watchOS(.v9), .visionOS(.v1) ], products: [ .library(name: "json", targets: ["json"]) diff --git a/README.md b/README.md index ae0ad12d2..18665dbf8 100644 --- a/README.md +++ b/README.md @@ -1202,15 +1202,18 @@ language bindings, format converters, and the like. See the curated [Ecosystem]( Though it's 2026 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work: -- GCC 4.8 - 14.2 (and possibly later) -- Clang 3.4 - 21.0 (and possibly later) -- Apple Clang 9.1 - 16.0 (and possibly later) -- Intel C++ Compiler 17.0.2 (and possibly later) -- Nvidia CUDA Compiler 11.0.221 (and possibly later) -- Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later) -- Microsoft Visual C++ 2017 / Build Tools 15.5.180.51428 (and possibly later) -- Microsoft Visual C++ 2019 / Build Tools 16.3.1+1def00d3d (and possibly later) -- Microsoft Visual C++ 2022 / Build Tools 19.30.30709.0 (and possibly later) +- GCC 4.8 - 16.2 (and possibly later) +- Clang 3.4 - 22.1 (and possibly later) +- Apple Clang 15.0 - 21.0 (and possibly later) +- Intel C++ Compiler Classic (icpc) 2021.10 +- Intel oneAPI DPC++/C++ Compiler (icpx) 2025.3 (and possibly later) +- NVIDIA CUDA Compiler (nvcc) 11.8 - 12.6 (and possibly later) +- NVIDIA HPC SDK C++ Compiler (nvc++) 25.5 (and possibly later) +- Microsoft Visual C++ 2015 / MSVC 19.0 (and possibly later) +- Microsoft Visual C++ 2017 / MSVC 19.16 (and possibly later) +- Microsoft Visual C++ 2019 / MSVC 19.29 (and possibly later) +- Microsoft Visual C++ 2022 / MSVC 19.44 (and possibly later) +- Microsoft Visual C++ 2026 / MSVC 19.51 (and possibly later) I would be happy to learn about other compilers/versions. @@ -1401,7 +1404,7 @@ The library is compliant to version 3.3 of the [**REUSE specification**](https:/ - Every source file contains an SPDX copyright header. - The full text of all licenses used in the repository can be found in the `LICENSES` folder. -- File `.reuse/dep5` contains an overview of all files' copyrights and licenses. +- File `REUSE.toml` contains an overview of all files' copyrights and licenses. - Run `pipx run reuse lint` to verify the project's REUSE compliance and `pipx run reuse spdx` to generate a SPDX SBOM. ## Contact diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 000000000..47bcab16a --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,52 @@ +version = 1 +SPDX-PackageName = "json" +SPDX-PackageSupplier = "Niels Lohmann " +SPDX-PackageDownloadLocation = "https://github.com/nlohmann/json" + +[[annotations]] +path = "**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2013-2026 Niels Lohmann " +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = "include/nlohmann/thirdparty/hedley.hpp" +precedence = "aggregate" +SPDX-FileCopyrightText = "2016-2021 Evan Nemerson " +SPDX-License-Identifier = "CC0" + +[[annotations]] +path = "include/nlohmann/detail/meta/cpp_future.hpp" +precedence = "aggregate" +SPDX-FileCopyrightText = "2013-2026 Niels Lohmann and 2018 The Abseil Authors" +SPDX-License-Identifier = "MIT AND Apache-2.0" + +[[annotations]] +path = "tests/thirdparty/doctest/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2016-2023 Viktor Kirilov" +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = "tests/thirdparty/fifo_map/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2015-2017 Niels Lohmann" +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = "tests/thirdparty/imapdl/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2017 Georg Sauthoff " +SPDX-License-Identifier = "GPL-3.0-only" + +[[annotations]] +path = "tools/amalgamate/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2012 Erik Edlund " +SPDX-License-Identifier = "BSD-3-Clause" + +[[annotations]] +path = "tools/gdb_pretty_printer/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2020 Hannes Domani " +SPDX-License-Identifier = "MIT" diff --git a/cmake/scripts/gen_bazel_build_file.cmake b/cmake/scripts/gen_bazel_build_file.cmake index a781a2e3f..ca5069cb0 100644 --- a/cmake/scripts/gen_bazel_build_file.cmake +++ b/cmake/scripts/gen_bazel_build_file.cmake @@ -48,6 +48,7 @@ cc_library( name = "singleheader-json", hdrs = [ "single_include/nlohmann/json.hpp", + "single_include/nlohmann/json_fwd.hpp", ], includes = ["single_include"], visibility = ["//visibility:public"], diff --git a/cmake/scripts/gen_hedley_undef_check.cmake b/cmake/scripts/gen_hedley_undef_check.cmake index fc8cfec2c..f796588c6 100644 --- a/cmake/scripts/gen_hedley_undef_check.cmake +++ b/cmake/scripts/gen_hedley_undef_check.cmake @@ -64,7 +64,7 @@ if(MODE STREQUAL "undef") # recipe is self-contained and its output is byte-stable across reruns. # The embedded SPDX tags below are part of the *generated* file's # content, not a REUSE header for this .cmake script itself (which is - # already covered by the blanket "Files: *" rule in .reuse/dep5) -- keep + # already covered by the blanket path = "**" rule in REUSE.toml) -- keep # them wrapped in REUSE-IgnoreStart/End so `reuse lint` does not try to # parse "MIT\n")" as this file's own SPDX-License-Identifier value. # REUSE-IgnoreStart diff --git a/docs/mkdocs/docs/integration/cmake.md b/docs/mkdocs/docs/integration/cmake.md index d75aef47b..9492efe9f 100644 --- a/docs/mkdocs/docs/integration/cmake.md +++ b/docs/mkdocs/docs/integration/cmake.md @@ -126,7 +126,7 @@ automatically download a release as a dependency at configure time. ### `JSON_BuildTests` -Build the unit tests when [`BUILD_TESTING`](https://cmake.org/cmake/help/latest/command/enable_testing.html) is enabled. This option is `ON` by default if the library's CMake project is the top project. That is, when integrating the library as described above, the test suite is not built unless explicitly switched on with this option. +Build the unit tests when [`BUILD_TESTING`](https://cmake.org/cmake/help/latest/command/enable_testing.html) is enabled. This option is `ON` by default if the library's CMake project is the top project and the `tests` directory exists (the release archive `json.tar.xz` does not contain it). That is, when integrating the library as described above, the test suite is not built unless explicitly switched on with this option. ### `JSON_CI`