Skip to content

Commit

Permalink
DOC: adding example and usage for CMake and CMake with hunter
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-42 committed Jul 31, 2017
1 parent 966989a commit 805ae56
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.


## Integration
### Manual integration

The single required source, file `json.hpp` is in the `src` directory or [released here](https://github.com/nlohmann/json/releases). All you need to do is add
The single required source, file `json.hpp` is in the `src` directory or [released here](https://github.com/nlohmann/json/releases). All you need to do is add

```cpp
#include "json.hpp"
Expand All @@ -64,12 +65,47 @@ using json = nlohmann::json;

to the files you want to use JSON objects. That's it. Do not forget to set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).

### CMake

If you are using CMake, just download the lates release, run ``` cd <path/build/folder> && cmake <path/to/nlohman_json/> && make install ```
To use it in your own project ``` CMakeLists.txt ```
```cmake
find_package(nlohmann_json CONFIG REQUIRED)
target_link_libraries(<YourTargetName> nlohmann_json)
```

### CMake with hunter (package manager)

You can also use the CMake package manager [hunter](https://github.com/ruslo/hunter) to automatically download ``` nlohman_json ``` for you.
```cmake
HunterGate( # must be before project()
URL "https://github.com/ruslo/hunter/archive/v0.19.52.tar.gz"
SHA1 "6d3a8135ba62726d810fd8c8c7d97980fa6c3b4a"
)
[...]
hunter_add_package(nlohmann_json)
find_package(nlohmann_json CONFIG REQUIRED)
target_link_libraries(... nlohmann_json)
```
This downloads, compiles, adds includes and links all what is needed automatically. For more details see [nlohman_json hunter package](https://github.com/ruslo/hunter/wiki/pkg.nlohmann_json)


### OS X and Homebrew

:beer: If you are using OS X and [Homebrew](http://brew.sh), just type `brew tap nlohmann/json` and `brew install nlohmann_json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann_json --HEAD`.

### Meson Build System

If you are using the [Meson Build System](http://mesonbuild.com), then you can wrap this repo as a subproject.

### Conan

If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `jsonformoderncpp/x.y.z@vthiery/stable` to your `conanfile.py`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/vthiery/conan-jsonformoderncpp/issues) if you experience problems with the packages.




:warning: [Version 3.0.0](https://github.com/nlohmann/json/wiki/Road-toward-3.0.0) is currently under development. Branch `develop` is used for the ongoing work and is probably **unstable**. Please use the `master` branch for the last stable version 2.1.1.


Expand Down

0 comments on commit 805ae56

Please sign in to comment.