Add nlohmann::json library

This commit is contained in:
Lexi / Zoe 2026-05-24 22:54:27 +02:00
parent eb98beac43
commit 3addd01f54
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
3 changed files with 65 additions and 0 deletions

View file

@ -4,6 +4,7 @@ defaults:
-Wall
-Wextra
-pedantic
-Ivendor/nlohmann_json/include
-Ivendor/RmlUi/Include
linker_args: >-
-lSDL3

51
src/vendor/nlohmann/json.cppm vendored Normal file
View file

@ -0,0 +1,51 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.12.0 (develop branch)
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
module;
// GCC workaround for C++ modules support.
// When using C++20 modules, some compilers (particularly GCC) may have issues
// with template instantiations in the module preamble. If you encounter
// "redefinition" errors when including nlohmann/json.hpp, try one of:
// 1. Include nlohmann/json.hpp in your module preamble BEFORE other #includes
// 2. Or use: import nlohmann.json; instead of #include <nlohmann/json.hpp>
// 3. Or upgrade to a newer GCC version with better modules support.
// See: https://github.com/nlohmann/json/issues/5103
#include <nlohmann/json.hpp>
// NOTE: Module renamed from nlohmann.json to match directory structure
export module vendor.nlohmann.json;
export NLOHMANN_JSON_NAMESPACE_BEGIN
using NLOHMANN_JSON_NAMESPACE::adl_serializer;
using NLOHMANN_JSON_NAMESPACE::basic_json;
using NLOHMANN_JSON_NAMESPACE::json;
using NLOHMANN_JSON_NAMESPACE::json_pointer;
using NLOHMANN_JSON_NAMESPACE::ordered_json;
using NLOHMANN_JSON_NAMESPACE::ordered_map;
using NLOHMANN_JSON_NAMESPACE::to_string;
inline namespace literals
{
inline namespace json_literals
{
using NLOHMANN_JSON_NAMESPACE::literals::json_literals::operator""_json;
using NLOHMANN_JSON_NAMESPACE::literals::json_literals::operator""_json_pointer;
} // namespace json_literals
} // namespace literals
// Note: the following nlohmann::detail symbols must be exported due to
// an MSVC bug failing to compile without these symbols visible (ticket #3970)
namespace detail
{
using NLOHMANN_JSON_NAMESPACE::detail::json_sax_dom_callback_parser;
using NLOHMANN_JSON_NAMESPACE::detail::unknown_size;
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END

13
vendor/README.md vendored
View file

@ -10,6 +10,19 @@ For now, SDL3 and SDL3_image need to be installed on the system. They should be
Same for freetype, which is required by RmlUi.
## nlohmann::json
[JSON for Modern C++](https://github.com/nlohmann/json).
Within the `vendor` directory, run:
```shell
# We're using the default branch (develop) here because the latest release does not support C++20 modules yet.
# (Last commit known working: 484483aca)
git clone git@github.com:nlohmann/json.git nlohmann_json
```
## RmlUi
[RmlUi](https://github.com/mikke89/RmlUi) is a UI library.