diff --git a/integration/cmake.md b/integration/cmake.md index d75aef47b..9492efe9f 100644 --- a/integration/cmake.md +++ b/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` diff --git a/integration/cmake/index.html b/integration/cmake/index.html index 08d429eb9..b1a56e638 100644 --- a/integration/cmake/index.html +++ b/integration/cmake/index.html @@ -46,7 +46,7 @@ GIT_REPOSITORY https://github.com/nlohmann/json GIT_TAG v3.12.0 ) -
However, the repository https://github.com/nlohmann/json download size is quite large.
JSON_BuildTests¶Build the unit tests when BUILD_TESTING 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.
JSON_CI¶Enable CI build targets. The exact targets are used during the several CI steps and are subject to change without notice. This option is OFF by default.
JSON_DeleteDeprecatedFunctions¶Delete the deprecated functions instead of only deprecating them by defining the macro JSON_DELETE_DEPRECATED_FUNCTIONS. This option is OFF by default.
JSON_Diagnostics¶Enable extended diagnostic messages by defining macro JSON_DIAGNOSTICS. This option is OFF by default.
Does not apply to a pre-installed package
This option only takes effect when building nlohmann/json from source as part of your own CMake project (e.g. via FetchContent or add_subdirectory). It has no effect on a package that was already built and installed elsewhere (Homebrew, vcpkg, a system package, etc.) — the resulting compile definition is baked into the exported nlohmann_jsonTargets.cmake at install time, and set(JSON_Diagnostics ON) before find_package() does not change it (verified against the Homebrew-installed package: the exported target still carries a fixed $<$<BOOL:OFF>:JSON_DIAGNOSTICS=1>, regardless of any variable set in the consuming project).
To enable extended diagnostics for a pre-installed package, override the imported target's property directly after find_package():
find_package(nlohmann_json REQUIRED)
+However, the repository https://github.com/nlohmann/json download size is quite large.
JSON_BuildTests¶Build the unit tests when BUILD_TESTING 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¶Enable CI build targets. The exact targets are used during the several CI steps and are subject to change without notice. This option is OFF by default.
JSON_DeleteDeprecatedFunctions¶Delete the deprecated functions instead of only deprecating them by defining the macro JSON_DELETE_DEPRECATED_FUNCTIONS. This option is OFF by default.
JSON_Diagnostics¶Enable extended diagnostic messages by defining macro JSON_DIAGNOSTICS. This option is OFF by default.
Does not apply to a pre-installed package
This option only takes effect when building nlohmann/json from source as part of your own CMake project (e.g. via FetchContent or add_subdirectory). It has no effect on a package that was already built and installed elsewhere (Homebrew, vcpkg, a system package, etc.) — the resulting compile definition is baked into the exported nlohmann_jsonTargets.cmake at install time, and set(JSON_Diagnostics ON) before find_package() does not change it (verified against the Homebrew-installed package: the exported target still carries a fixed $<$<BOOL:OFF>:JSON_DIAGNOSTICS=1>, regardless of any variable set in the consuming project).
To enable extended diagnostics for a pre-installed package, override the imported target's property directly after find_package():
find_package(nlohmann_json REQUIRED)
set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "JSON_DIAGNOSTICS=1")
This only works cleanly when your project is the sole consumer of that imported target. If nlohmann_json is pulled in from more than one place in your dependency graph with different JSON_DIAGNOSTICS values, you may see a "JSON_DIAGNOSTICS" redefined compiler error, since conflicting -D flags can end up on the same compile command line.
JSON_Diagnostic_Positions¶Enable position diagnostics by defining macro JSON_DIAGNOSTIC_POSITIONS. This option is OFF by default.
JSON_DisableEnumSerialization¶Disable default enum serialization by defining the macro JSON_DISABLE_ENUM_SERIALIZATION. This option is OFF by default.
JSON_DisableTupleReferenceConversion¶Disable the conversion from a one-element std::tuple holding a reference to a JSON value by defining the macro JSON_DISABLE_TUPLE_REFERENCE_CONVERSION. This option is OFF by default.
JSON_FastTests¶Skip expensive/slow test suites. This option is OFF by default. Depends on JSON_BuildTests.
JSON_GlobalUDLs¶Place user-defined string literals in the global namespace by defining the macro JSON_USE_GLOBAL_UDLS. This option is ON by default; see the migration guide for how to prepare code for the next major release, where the literals are removed from the global namespace.
JSON_ImplicitConversions¶Enable implicit conversions by defining macro JSON_USE_IMPLICIT_CONVERSIONS. This option is ON by default; see the migration guide for how to prepare code for the next major release, where implicit conversions are switched off by default.
JSON_Install¶Install CMake targets during install step. This option is ON by default if the library's CMake project is the top project. Installing also generates a pkg-config file for tools that rely on pkg-config instead of CMake.
JSON_LegacyDiscardedValueComparison¶Enable the (incorrect) legacy comparison behavior of discarded JSON values by defining macro JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON. This option is OFF by default.
JSON_MultipleHeaders¶Use the non-amalgamated version of the library. This option is ON by default.
JSON_SystemInclude¶Treat the library headers like system headers (i.e., adding SYSTEM to the target_include_directories call) to check for this library by tools like Clang-Tidy. This option is OFF by default.
JSON_StrictBinaryUTF8¶Check string values and object keys for valid UTF-8 in the CBOR, UBJSON, BJData, and BSON writers, by defining the macro JSON_STRICT_BINARY_UTF8. This option is OFF by default.
JSON_StrictNulHandling¶Reject a '\0' (NUL) byte in the input instead of treating it as end of input, by defining the macro JSON_STRICT_NUL_HANDLING. This option is OFF by default.
JSON_TestSimdutf¶Build the unit tests against the simdutf UTF-8 validation backend by defining JSON_USE_SIMDUTF for every test target. simdutf is fetched during configuration; its version is set by the cache variable JSON_SIMDUTF_VERSION. This option is OFF by default. Depends on JSON_BuildTests.
JSON_Valgrind¶Execute the test suite with Valgrind. This option is OFF by default. Depends on JSON_BuildTests.
NLOHMANN_JSON_BUILD_MODULES¶Build the experimental C++ module nlohmann.json (requires CMake 3.28 or later and C++20). This option is OFF by default.
A consuming project must link the dedicated nlohmann_json_modules CMake target (not just nlohmann_json::nlohmann_json) for import nlohmann.json; to resolve:
set(NLOHMANN_JSON_BUILD_MODULES ON)
@@ -55,4 +55,4 @@
add_executable(myproject main.cpp)
target_link_libraries(myproject PRIVATE nlohmann_json_modules)
target_compile_definitions(myproject PRIVATE NLOHMANN_JSON_BUILD_MODULES)
-