@@ -64,72 +64,112 @@ int main()
64
64
See [ ` QUICKSTART-CPP.md ` ] ( ./QUICKSTART-CPP.md ) for more details.
65
65
66
66
Dependency
67
- -----
67
+ ----------
68
+
68
69
msgpack-c requires [ boost library] ( https://www.boost.org/ ) .
69
- msgpack-c depends on only boost headers. You don't need to link boost libraries.
70
+ C++ version of msgpack-c itself is a header-only library and depends only on
71
+ boost headers. Tests depend on boost unit test framework and are linked with
72
+ it, so if you want to build them, you need to have this dependency installed.
70
73
71
74
Usage
72
75
-----
73
76
74
- ### C++ Header Only Library
77
+ - If you build your project with cmake, you can find msgpack-c with a
78
+ canonical cmake-way:
79
+
80
+ ``` cmake
81
+ # ...
82
+ find_package(msgpack REQUIRED)
83
+ # ...
84
+ target_link_libraries(your_target_name <PRIVATE/PUBLIC/INTERFACE> msgpackc-cxx)
85
+ # ...
86
+ ```
87
+
88
+ This will search for ` msgpack ` cmake package in a system prefix and in
89
+ prefixes from ` CMAKE_PREFIX_PATH ` . Note that msgpack-c depends on boost
90
+ headers, and ` msgpack ` cmake package depends on ` Boost ` cmake package. The
91
+ library is header-only and ` target_link_libraries ` command just adds path
92
+ to msgpack-c headers to your compiler's include path.
75
93
76
- When you use msgpack on C++, you can just add
77
- msgpack-c/include to your include path:
94
+ A usage example can be found at [ test-install] ( test-install ) directory.
78
95
79
- g++ -I msgpack-c/include -I path_to_boost your_source_file.cpp
96
+ - If you do not use cmake, you can just add path yo msgpack-c and boost
97
+ headers to your include path:
80
98
99
+ ``` bash
100
+ g++ -I msgpack-c/include -I path_to_boost your_source_file.cpp
101
+ ```
81
102
82
- ### Building and Installing
103
+ Building and Installing
104
+ -----------------------
83
105
84
- #### Install from git repository
106
+ ### Install from git repository
85
107
86
- ##### Using the Terminal (CLI)
108
+ #### Using the Terminal (CLI)
87
109
88
110
You will need:
89
111
90
- - ` gcc >= 4.1.0 `
91
- - ` cmake >= 3.0 .0 `
112
+ - ` gcc >= 4.1.0 `
113
+ - ` cmake >= 3.1 .0 `
92
114
93
115
C++03:
94
116
95
- $ git clone https://github.com/msgpack/msgpack-c.git
96
- $ cd msgpack-c
97
- $ git checkout cpp_master
98
- $ cmake .
99
- $ make
100
- $ sudo make install
117
+ ``` bash
118
+ git clone https://github.com/msgpack/msgpack-c.git
119
+ cd msgpack-c
120
+ git checkout cpp_master
121
+ cmake .
122
+ sudo cmake --build . --target install
123
+ ```
101
124
102
- If you want to setup C++17 version of msgpack instead,
103
- execute the following commands:
125
+ If you want to build tests with different C++ version, you can use
126
+ ` MSGPACK_CXX11 ` , ` MSGPACK_CXX14 ` , ` MSGPACK_CXX17 ` , ` MSGPACK_CXX20 ` options.
127
+ Just replace the line
104
128
105
- $ git clone https://github.com/msgpack/msgpack-c.git
106
- $ cd msgpack-c
107
- $ git checkout cpp_master
108
- $ cmake -DMSGPACK_CXX17=ON .
109
- $ make
110
- $ sudo make install
129
+ ``` bash
130
+ cmake .
131
+ ```
111
132
112
- For C++11, replace ` -DMSGPACK_CXX17=ON ` with ` -DMSGPACK_CXX11=ON ` .
133
+ with a line like that:
113
134
114
- ` MSGPACK_CXX11 ` and ` MSGPACK_CXX17 ` flags do not affect installation. They just switch test cases. All files are installed in every settings.
135
+ ``` bash
136
+ cmake -DMSGPACK_CXX20=ON .
137
+ ```
115
138
139
+ Note that these flags do not affect installation. They just switch test cases.
140
+ All files are installed in every settings.
116
141
117
- #### GUI on Windows
142
+ If you don't have superuser permissions or don't want to install the library
143
+ to a system-wide prefix, you can use ` CMAKE_INSTALL_PREFIX ` option like that:
118
144
119
- Clone msgpack-c git repository.
145
+ ``` bash
146
+ cmake -DCMAKE_INSTALL_PREFIX=/your/custom/prefix .
147
+ ```
148
+
149
+ Other useful options:
120
150
121
- $ git clone https://github.com/msgpack/msgpack-c.git
151
+ - ` MSGPACK_BUILD_TESTS ` (default ` OFF ` ): build tests
152
+ - ` MSGPACK_BUILD_EXAMPLES ` (default ` OFF ` ): build examples
153
+ - ` MSGPACK_32BIT ` (default ` OFF ` ): 32bit compile
154
+ - ` MSGPACK_USE_X3_PARSE ` (default ` OFF ` ): use Boost X3 parse
155
+ (note that it requires C++14 or newer)
156
+
157
+ #### GUI on Windows
122
158
123
- or using GUI git client.
159
+ Clone msgpack-c git repository with the command:
160
+
161
+ ```
162
+ git clone https://github.com/msgpack/msgpack-c.git
163
+ ```
124
164
125
- e.g.) tortoise git https://code.google.com/p/tortoisegit/
165
+ or using GUI git client ( e.g. [ tortoise git] ( https://code.google.com/p/tortoisegit/ ) ).
126
166
127
- 1 . Checkout to cpp_master branch
167
+ 1 . Checkout to ` cpp_master ` branch
128
168
129
169
2 . Launch [ cmake GUI client] ( http://www.cmake.org/cmake/resources/software.html ) .
130
170
131
- 3 . Set 'Where is the source code:' text box and 'Where to build
132
- the binaries:' text box.
171
+ 3 . Set 'Where is the source code:' text box and
172
+ 'Where to build the binaries:' text box.
133
173
134
174
4 . Click 'Configure' button.
135
175
@@ -141,7 +181,8 @@ the binaries:' text box.
141
181
142
182
8 . Build all.
143
183
144
- ### Documentation
184
+ Documentation
185
+ -------------
145
186
146
187
You can get additional information including the tutorial on the
147
188
[ wiki] ( https://github.com/msgpack/msgpack-c/wiki ) .
0 commit comments