Skip to content

Commit 07623b7

Browse files
committed
Merge branch 'master' into 0.y.z
2 parents f1ff137 + bcb83b9 commit 07623b7

File tree

5 files changed

+43
-37
lines changed

5 files changed

+43
-37
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library i
2525

2626
SET(RUNTIME_INSTALL_DIR bin
2727
CACHE PATH "Install dir for executables and dlls")
28-
SET(ARCHIVE_INSTALL_DIR lib${LIB_SUFFIX}
28+
SET(ARCHIVE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
2929
CACHE PATH "Install dir for static libraries")
30-
SET(LIBRARY_INSTALL_DIR lib${LIB_SUFFIX}
30+
SET(LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
3131
CACHE PATH "Install dir for shared libraries")
32-
SET(INCLUDE_INSTALL_DIR include
32+
SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include
3333
CACHE PATH "Install dir for headers")
3434
SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake
3535
CACHE PATH "Install dir for cmake package config files")

README.md

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ format to store user input files.
1919
* `0.y.z` can be used with older compilers.
2020
* Major versions maintain binary-compatibility.
2121

22-
Using JsonCpp in your project
22+
# Using JsonCpp in your project
2323
-----------------------------
24-
The recommended approach to integrating JsonCpp in your project is to build
25-
the amalgamated source (a single `.cpp` file) with your own build system. This
26-
ensures consistency of compilation flags and ABI compatibility. See the section
27-
"Generating amalgamated source and header" for instructions.
24+
The recommended approach to integrating JsonCpp in your project is to include
25+
the [amalgamated source](#generating-amalgamated-source-and-header) (a single
26+
`.cpp` file and two `.h` files) in your project, and compile and build as you
27+
would any other source file. This ensures consistency of compilation flags and
28+
ABI compatibility, issues which arise when building shared or static
29+
libraries. See the next section for instructions.
2830

2931
The `include/` should be added to your compiler include path. Jsoncpp headers
3032
should be included as follow:
@@ -34,6 +36,31 @@ should be included as follow:
3436
If JsonCpp was built as a dynamic library on Windows, then your project needs to
3537
define the macro `JSON_DLL`.
3638

39+
Generating amalgamated source and header
40+
----------------------------------------
41+
JsonCpp is provided with a script to generate a single header and a single
42+
source file to ease inclusion into an existing project. The amalgamated source
43+
can be generated at any time by running the following command from the
44+
top-directory (this requires Python 2.6):
45+
46+
python amalgamate.py
47+
48+
It is possible to specify header name. See the `-h` option for detail.
49+
50+
By default, the following files are generated:
51+
* `dist/jsoncpp.cpp`: source file that needs to be added to your project.
52+
* `dist/json/json.h`: corresponding header file for use in your project. It is
53+
equivalent to including `json/json.h` in non-amalgamated source. This header
54+
only depends on standard headers.
55+
* `dist/json/json-forwards.h`: header that provides forward declaration of all
56+
JsonCpp types.
57+
58+
The amalgamated sources are generated by concatenating JsonCpp source in the
59+
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
60+
of other headers.
61+
62+
# Contributing to JsonCpp
63+
3764
Building and testing with CMake
3865
-------------------------------
3966
[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:
6794

6895
mkdir -p build/debug
6996
cd build/debug
70-
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -G "Unix Makefiles" ../..
97+
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../..
7198
make
7299

73-
Running `cmake -`" will display the list of available generators (passed using
100+
Running `cmake -h` will display the list of available generators (passed using
74101
the `-G` option).
75102

76103
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
106133
environment by running `vcvars32.bat` (e.g. MSVC 2008 command prompt) before
107134
running SCons.
108135

109-
# Running the tests manually
136+
## Running the tests manually
110137
You need to run tests manually only if you are troubleshooting an issue.
111138

112139
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:
142169

143170
See `doxybuild.py --help` for options.
144171

145-
Generating amalgamated source and header
146-
----------------------------------------
147-
JsonCpp is provided with a script to generate a single header and a single
148-
source file to ease inclusion into an existing project. The amalgamated source
149-
can be generated at any time by running the following command from the
150-
top-directory (this requires Python 2.6):
151-
152-
python amalgamate.py
153-
154-
It is possible to specify header name. See the `-h` option for detail.
155-
156-
By default, the following files are generated:
157-
* `dist/jsoncpp.cpp`: source file that needs to be added to your project.
158-
* `dist/json/json.h`: corresponding header file for use in your project. It is
159-
equivalent to including `json/json.h` in non-amalgamated source. This header
160-
only depends on standard headers.
161-
* `dist/json/json-forwards.h`: header that provides forward declaration of all
162-
JsonCpp types.
163-
164-
The amalgamated sources are generated by concatenating JsonCpp source in the
165-
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
166-
of other headers.
167-
168172
Adding a reader/writer test
169173
---------------------------
170174
To add a test, you need to create two files in test/data:

doxybuild.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def run_cmd(cmd, silent=False):
7272
if silent:
7373
status, output = getstatusoutput(cmd)
7474
else:
75-
status, output = os.system(' '.join(cmd)), ''
75+
status, output = subprocess.call(cmd), ''
7676
if status:
7777
msg = 'Error while %s ...\n\terror=%d, output="""%s"""' %(info, status, output)
7878
raise Exception(msg)

pkg-config/jsoncpp.pc.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
22
exec_prefix=${prefix}
3-
libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@
4-
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
3+
libdir=@LIBRARY_INSTALL_DIR@
4+
includedir=@INCLUDE_INSTALL_DIR@
55

66
Name: jsoncpp
77
Description: A C++ library for interacting with JSON

src/lib_json/json_writer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
3131
#define snprintf _snprintf
32+
#elif defined(__ANDROID__)
33+
#define snprintf snprintf
3234
#elif __cplusplus >= 201103L
3335
#define snprintf std::snprintf
3436
#endif

0 commit comments

Comments
 (0)