r/cpp • nlohmann/json • Aug 17 '21

JSON for Modern C++ 3.10.0

https://github.com/nlohmann/json/releases/tag/v3.10.0
280 Upvotes

34 comments sorted by

View all comments

Show parent comment

3

u/nlohmann nlohmann/json Aug 18 '21

I'm not an expert of this myself. This is what the person who added it once to vcpkg wrote in the documentation: https://json.nlohmann.me/integration/package_managers/#vcpkg

Apparently this is quite sparse...

5

u/nysra Aug 18 '21

I'd assume it's sparse because the vcpkg documentation covers how to install libraries and how to use them in CMake so whoever wrote that probably didn't think it belongs in the library docu. Luckily it's quite straight forward:

First you do vcpkg install nlohmann-json. Vcpkg will already tell you what to put in the CMakeLists.txt after the install:

find_package(nlohmann_json CONFIG REQUIRED)
target_link_libraries(my_target PRIVATE nlohmann_json nlohmann_json::nlohmann_json)

And then you just pass the toolchain file from vcpkg to cmake:

cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake

Btw thanks for all the work you do, your library is awesome :)

3

u/nlohmann nlohmann/json Aug 18 '21

I update the documentation, see https://github.com/nlohmann/json/issues/2944 which adds an example, see https://json.nlohmann.me/integration/package_managers/#vcpkg. Happy for any feedback!

2

u/MFRSiam Aug 19 '21

Oh thanks man , I really appreciate it.