Fix CI failures of the unity test build

- keep JSON_DISABLE_ENUM_SERIALIZATION and
  JSON_DISABLE_TUPLE_REFERENCE_CONVERSION defined with
  JSON_TEST_KEEP_MACROS, so that every file of a batch sees them, not only
  the first one
- mark JSON_TESTS_PRIVATE in the generated batch file as used, as GCC and
  Clang report an unused definition when the first file defines it again
  (-Wunused-macros)
- suppress bugprone-suspicious-include for the #include-d .cpp files
- avoid local json aliases and variables that hide a global json of
  another file in the same batch (MSVC C4459)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-09 23:23:04 +02:00
1 parent 993e37e7ec
commit 769c5cde57
5 files changed
+79 -82

No files matched your search

+4 -1
View File
@@ -290,9 +290,12 @@ function(_json_test_add_unity_batch batch_name cxx_standard main private)
if(private)
string(APPEND batch_content "// at least one file of this batch needs access to private members of the library\n")
string(APPEND batch_content "#define JSON_TESTS_PRIVATE\n")
# the files define the macro again; mark this definition as used, as
# -Wunused-macros reports an unused definition when it is redefined
string(APPEND batch_content "#ifdef JSON_TESTS_PRIVATE\n#endif\n")
endif()
foreach(file ${ARGN})
string(APPEND batch_content "#include \"${file}\"\n")
string(APPEND batch_content "#include \"${file}\" // NOLINT(bugprone-suspicious-include)\n")
endforeach()
# only touch the generated file if it changed to keep incremental builds incremental