diff --git a/README.md b/README.md index f9c65e8bb..1d74b1c02 100644 --- a/README.md +++ b/README.md @@ -1252,7 +1252,7 @@ If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example). -If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can use the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json). Please see the vcpkg project for any issues regarding the packaging. +If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can install the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json) with `vcpkg install nlohmann-json` and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging. If you are using [cget](https://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`). diff --git a/doc/mkdocs/docs/integration/package_managers.md b/doc/mkdocs/docs/integration/package_managers.md index b860296ab..d6ce2e062 100644 --- a/doc/mkdocs/docs/integration/package_managers.md +++ b/doc/mkdocs/docs/integration/package_managers.md @@ -110,7 +110,40 @@ If you are using [Buckaroo](https://buckaroo.pm), you can install this library's ## vcpkg -If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can use the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json). Please see the vcpkg project for any issues regarding the packaging. +If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can install the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json) with `vcpkg install nlohmann-json` and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging. + +??? example + + 1. Create the following files: + + === "CMakeLists.txt" + + ```cmake + --8<-- "integration/vcpkg/CMakeLists.txt" + ``` + + === "example.cpp" + + ```cpp + --8<-- "integration/vcpkg/example.cpp" + ``` + + 2. Install package: + + ```sh + vcpkg install nlohmann-json + ``` + + 3. Build: + + ```sh + mkdir build + cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake --build . + ``` + + Note you need to adjust `/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake` to your system. ## cget diff --git a/doc/mkdocs/docs/integration/vcpkg/CMakeLists.txt b/doc/mkdocs/docs/integration/vcpkg/CMakeLists.txt new file mode 100644 index 000000000..d31f4e835 --- /dev/null +++ b/doc/mkdocs/docs/integration/vcpkg/CMakeLists.txt @@ -0,0 +1,7 @@ +project(json_example) +cmake_minimum_required(VERSION 2.8.12) + +find_package(nlohmann_json CONFIG REQUIRED) + +add_executable(json_example example.cpp) +target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json) diff --git a/doc/mkdocs/docs/integration/vcpkg/example.cpp b/doc/mkdocs/docs/integration/vcpkg/example.cpp new file mode 100644 index 000000000..e5a31be4b --- /dev/null +++ b/doc/mkdocs/docs/integration/vcpkg/example.cpp @@ -0,0 +1,9 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + std::cout << json::meta() << std::endl; +}