mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-08-09 04:56:30 -04:00
Created Building (markdown)
parent
520a440570
commit
c924bd3267
98
Building.md
Normal file
98
Building.md
Normal file
@ -0,0 +1,98 @@
|
||||
### Building and testing with Meson/Ninja
|
||||
Thanks to David Seifert (@SoapGentoo), we (the maintainers) now use [meson](http://mesonbuild.com/) and [ninja](https://ninja-build.org/) to build for debugging, as well as for continuous integration (see [`travis.sh`](travis.sh) ). Other systems may work, but minor things like version strings might break.
|
||||
|
||||
First, install both meson (which requires Python3) and ninja.
|
||||
|
||||
Then,
|
||||
|
||||
cd jsoncpp/
|
||||
BUILD_TYPE=shared
|
||||
#BUILD_TYPE=static
|
||||
LIB_TYPE=debug
|
||||
#LIB_TYPE=release
|
||||
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
|
||||
ninja -v -C build-${LIB_TYPE} test
|
||||
|
||||
### Building and testing with CMake
|
||||
(Deprecated, but still works for now. The version string may soon be wrong.)
|
||||
|
||||
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most Linux system as package. On Ubuntu:
|
||||
|
||||
sudo apt-get install cmake
|
||||
|
||||
[CMake]: http://www.cmake.org
|
||||
|
||||
Note that Python is also required to run the JSON reader/writer tests. If
|
||||
missing, the build will skip running those tests.
|
||||
|
||||
When running CMake, a few parameters are required:
|
||||
|
||||
* A build directory where the makefiles/solution are generated. It is also used
|
||||
to store objects, libraries and executables files.
|
||||
* The generator to use: makefiles or Visual Studio solution? What version or
|
||||
Visual Studio, 32 or 64 bits solution?
|
||||
|
||||
Steps for generating solution/makefiles using `cmake-gui`:
|
||||
|
||||
* Make "source code" point to the source directory.
|
||||
* Make "where to build the binary" point to the directory to use for the build.
|
||||
* Click on the "Grouped" check box.
|
||||
* Review JsonCpp build options (tick `BUILD_SHARED_LIBS` to build as a
|
||||
dynamic library).
|
||||
* Click the configure button at the bottom, then the generate button.
|
||||
* The generated solution/makefiles can be found in the binary directory.
|
||||
|
||||
Alternatively, from the command-line on Unix in the source directory:
|
||||
|
||||
mkdir -p build/debug
|
||||
cd build/debug
|
||||
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../..
|
||||
make
|
||||
|
||||
For a good pkg-config file, add:
|
||||
|
||||
-DCMAKE_INSTALL_INCLUDEDIR=include/jsoncpp
|
||||
|
||||
Running `cmake -h` will display the list of available generators (passed using
|
||||
the `-G` option).
|
||||
|
||||
By default CMake hides compilation commands. This can be modified by specifying
|
||||
`-DCMAKE_VERBOSE_MAKEFILE=true` when generating makefiles.
|
||||
|
||||
### Building and testing with Conan
|
||||
(This works, but it currently uses `cmake`, which is deprecated.)
|
||||
|
||||
[Conan](https://www.conan.io/#/) is an open source package manager intended for C/C++ projects.
|
||||
It is cross platform and build system agnostic.
|
||||
|
||||
Conan requires Python for running, and can be installed using pip:
|
||||
|
||||
pip install conan
|
||||
|
||||
Detailed instructions can be found on [conan docs](http://docs.conan.io/en/latest/).
|
||||
|
||||
For build jsoncpp with conan, you need to create a [conanfile.txt](http://docs.conan.io/en/latest/reference/conanfile_txt.html) or a [conanfile.py](http://docs.conan.io/en/latest/reference/conanfile.html). The first is simpler, but the second is more flexible.
|
||||
|
||||
This is a sample conanfile.txt:
|
||||
|
||||
```
|
||||
[requires]
|
||||
jsoncpp/1.8.0@theirix/ci
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
```
|
||||
|
||||
**Note**: cmake is not required, you can use other [integrations](http://docs.conan.io/en/latest/integrations.html). Or you can set the appropriate environment variables, using [virtualenv generators](http://docs.conan.io/en/latest/mastering/virtualenv.html).
|
||||
|
||||
Then run the following command from the conanfile directory:
|
||||
|
||||
conan install --build missing
|
||||
|
||||
This will try to download the appropriate package for your settings (OS, compiler, architecture) from the [recipe packages](https://www.conan.io/source/jsoncpp/1.8.0/theirix/ci). If it is not found, the package will be built.
|
||||
|
||||
**Note**: you do not need to install cmake to build jsoncpp using conan, because the recipe will download it automatically.
|
||||
|
||||
If you need, you can customize the jsoncpp recipe. Just clone/fork [it from github](https://github.com/theirix/conan-jsoncpp/).
|
||||
|
||||
See [integrations instructions](http://docs.conan.io/en/latest/integrations.html) for how to use your build system with conan.
|
Loading…
x
Reference in New Issue
Block a user