Merge branch 'master' into 0.y.z

This commit is contained in:
Christopher Dunn 2015-06-18 22:34:40 -05:00
commit 07623b71f2
5 changed files with 43 additions and 37 deletions

View File

@ -25,11 +25,11 @@ SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library i
SET(RUNTIME_INSTALL_DIR bin SET(RUNTIME_INSTALL_DIR bin
CACHE PATH "Install dir for executables and dlls") CACHE PATH "Install dir for executables and dlls")
SET(ARCHIVE_INSTALL_DIR lib${LIB_SUFFIX} SET(ARCHIVE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
CACHE PATH "Install dir for static libraries") CACHE PATH "Install dir for static libraries")
SET(LIBRARY_INSTALL_DIR lib${LIB_SUFFIX} SET(LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
CACHE PATH "Install dir for shared libraries") CACHE PATH "Install dir for shared libraries")
SET(INCLUDE_INSTALL_DIR include SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include
CACHE PATH "Install dir for headers") CACHE PATH "Install dir for headers")
SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake
CACHE PATH "Install dir for cmake package config files") CACHE PATH "Install dir for cmake package config files")

View File

@ -19,12 +19,14 @@ format to store user input files.
* `0.y.z` can be used with older compilers. * `0.y.z` can be used with older compilers.
* Major versions maintain binary-compatibility. * Major versions maintain binary-compatibility.
Using JsonCpp in your project # Using JsonCpp in your project
----------------------------- -----------------------------
The recommended approach to integrating JsonCpp in your project is to build The recommended approach to integrating JsonCpp in your project is to include
the amalgamated source (a single `.cpp` file) with your own build system. This the [amalgamated source](#generating-amalgamated-source-and-header) (a single
ensures consistency of compilation flags and ABI compatibility. See the section `.cpp` file and two `.h` files) in your project, and compile and build as you
"Generating amalgamated source and header" for instructions. would any other source file. This ensures consistency of compilation flags and
ABI compatibility, issues which arise when building shared or static
libraries. See the next section for instructions.
The `include/` should be added to your compiler include path. Jsoncpp headers The `include/` should be added to your compiler include path. Jsoncpp headers
should be included as follow: should be included as follow:
@ -34,6 +36,31 @@ should be included as follow:
If JsonCpp was built as a dynamic library on Windows, then your project needs to If JsonCpp was built as a dynamic library on Windows, then your project needs to
define the macro `JSON_DLL`. define the macro `JSON_DLL`.
Generating amalgamated source and header
----------------------------------------
JsonCpp is provided with a script to generate a single header and a single
source file to ease inclusion into an existing project. The amalgamated source
can be generated at any time by running the following command from the
top-directory (this requires Python 2.6):
python amalgamate.py
It is possible to specify header name. See the `-h` option for detail.
By default, the following files are generated:
* `dist/jsoncpp.cpp`: source file that needs to be added to your project.
* `dist/json/json.h`: corresponding header file for use in your project. It is
equivalent to including `json/json.h` in non-amalgamated source. This header
only depends on standard headers.
* `dist/json/json-forwards.h`: header that provides forward declaration of all
JsonCpp types.
The amalgamated sources are generated by concatenating JsonCpp source in the
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
of other headers.
# Contributing to JsonCpp
Building and testing with CMake Building and testing with CMake
------------------------------- -------------------------------
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most [CMake][] is a C++ Makefiles/Solution generator. It is usually available on most
@ -67,10 +94,10 @@ Alternatively, from the command-line on Unix in the source directory:
mkdir -p build/debug mkdir -p build/debug
cd build/debug cd build/debug
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -G "Unix Makefiles" ../.. cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../..
make make
Running `cmake -`" will display the list of available generators (passed using Running `cmake -h` will display the list of available generators (passed using
the `-G` option). the `-G` option).
By default CMake hides compilation commands. This can be modified by specifying By default CMake hides compilation commands. This can be modified by specifying
@ -106,7 +133,7 @@ If you are building with Microsoft Visual Studio 2008, you need to set up the
environment by running `vcvars32.bat` (e.g. MSVC 2008 command prompt) before environment by running `vcvars32.bat` (e.g. MSVC 2008 command prompt) before
running SCons. running SCons.
# Running the tests manually ## Running the tests manually
You need to run tests manually only if you are troubleshooting an issue. You need to run tests manually only if you are troubleshooting an issue.
In the instructions below, replace `path/to/jsontest` with the path of the In the instructions below, replace `path/to/jsontest` with the path of the
@ -142,29 +169,6 @@ Run the Python script `doxybuild.py` from the top directory:
See `doxybuild.py --help` for options. See `doxybuild.py --help` for options.
Generating amalgamated source and header
----------------------------------------
JsonCpp is provided with a script to generate a single header and a single
source file to ease inclusion into an existing project. The amalgamated source
can be generated at any time by running the following command from the
top-directory (this requires Python 2.6):
python amalgamate.py
It is possible to specify header name. See the `-h` option for detail.
By default, the following files are generated:
* `dist/jsoncpp.cpp`: source file that needs to be added to your project.
* `dist/json/json.h`: corresponding header file for use in your project. It is
equivalent to including `json/json.h` in non-amalgamated source. This header
only depends on standard headers.
* `dist/json/json-forwards.h`: header that provides forward declaration of all
JsonCpp types.
The amalgamated sources are generated by concatenating JsonCpp source in the
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
of other headers.
Adding a reader/writer test Adding a reader/writer test
--------------------------- ---------------------------
To add a test, you need to create two files in test/data: To add a test, you need to create two files in test/data:

View File

@ -72,7 +72,7 @@ def run_cmd(cmd, silent=False):
if silent: if silent:
status, output = getstatusoutput(cmd) status, output = getstatusoutput(cmd)
else: else:
status, output = os.system(' '.join(cmd)), '' status, output = subprocess.call(cmd), ''
if status: if status:
msg = 'Error while %s ...\n\terror=%d, output="""%s"""' %(info, status, output) msg = 'Error while %s ...\n\terror=%d, output="""%s"""' %(info, status, output)
raise Exception(msg) raise Exception(msg)

View File

@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@ libdir=@LIBRARY_INSTALL_DIR@
includedir=${prefix}/@INCLUDE_INSTALL_DIR@ includedir=@INCLUDE_INSTALL_DIR@
Name: jsoncpp Name: jsoncpp
Description: A C++ library for interacting with JSON Description: A C++ library for interacting with JSON

View File

@ -29,6 +29,8 @@
#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below #if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
#define snprintf _snprintf #define snprintf _snprintf
#elif defined(__ANDROID__)
#define snprintf snprintf
#elif __cplusplus >= 201103L #elif __cplusplus >= 201103L
#define snprintf std::snprintf #define snprintf std::snprintf
#endif #endif