About pull request:
https://github.com/nlohmann/json/pull/2074
An error has been introduced by accepting the suggestions:
4be4a038cc
One was about removing ~~~, but it was meant to be replaced by ``` in
reality. This caused the README.md to be slightly broken.
Github issue:
https://github.com/nlohmann/json/issues/2073
nlohmann::json documents 2 way of depending on it using CMake
1) Copy-paste the project/source into your own project.
2) Install nlohman::json and then use find_package.
(1) pollutes your git repository, (2) requires everyone to install the
dependencies themselves.
Since 2018, CMake provide some kind of 'package manager' features using
[FetchContent](https://cmake.org/cmake/help/v3.17/module/FetchContent.html)
It gives the following:
~~~cmake
include(FetchContent)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json
GIT_TAG v3.7.3)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory( ${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
~~~
Then declares the dependency in the target using it:
~~~cmake
target_link_library(my_project PRIVATE nlohmann_json::nlohmann_json
~~~
This patch updates the documentation and provides tests.
I created a `nlohmann-json` package for `build2` (https://build2.org) that have been published on the central public repository https://cppget.org : https://cppget.org/nlohmann-json (at the moment you can see that there is only one version: 3.7.3).
The repository of the package code is there: https://github.com/build2-packaging/nlohmann-json and is owned by the build2 community now. (with build2 you can use either a repository like cppget.org or a git repository so both are useful to users for different use cases).
This patch just add the basic information as to how to use this library with build2.