Skip to content

Commit 7881431

Browse files
authored
Update README.md
1 parent 073394c commit 7881431

File tree

1 file changed

+77
-36
lines changed

1 file changed

+77
-36
lines changed

README.md

Lines changed: 77 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,72 +64,112 @@ int main()
6464
See [`QUICKSTART-CPP.md`](./QUICKSTART-CPP.md) for more details.
6565

6666
Dependency
67-
-----
67+
----------
68+
6869
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.
7073

7174
Usage
7275
-----
7376

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.
7593

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.
7895

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:
8098

99+
```bash
100+
g++ -I msgpack-c/include -I path_to_boost your_source_file.cpp
101+
```
81102

82-
### Building and Installing
103+
Building and Installing
104+
-----------------------
83105

84-
#### Install from git repository
106+
### Install from git repository
85107

86-
##### Using the Terminal (CLI)
108+
#### Using the Terminal (CLI)
87109

88110
You will need:
89111

90-
- `gcc >= 4.1.0`
91-
- `cmake >= 3.0.0`
112+
- `gcc >= 4.1.0`
113+
- `cmake >= 3.1.0`
92114

93115
C++03:
94116

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+
```
101124

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
104128

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+
```
111132

112-
For C++11, replace `-DMSGPACK_CXX17=ON` with `-DMSGPACK_CXX11=ON`.
133+
with a line like that:
113134

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+
```
115138

139+
Note that these flags do not affect installation. They just switch test cases.
140+
All files are installed in every settings.
116141

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:
118144

119-
Clone msgpack-c git repository.
145+
```bash
146+
cmake -DCMAKE_INSTALL_PREFIX=/your/custom/prefix .
147+
```
148+
149+
Other useful options:
120150

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
122158

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+
```
124164

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/)).
126166

127-
1. Checkout to cpp_master branch
167+
1. Checkout to `cpp_master` branch
128168

129169
2. Launch [cmake GUI client](http://www.cmake.org/cmake/resources/software.html).
130170

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.
133173

134174
4. Click 'Configure' button.
135175

@@ -141,7 +181,8 @@ the binaries:' text box.
141181

142182
8. Build all.
143183

144-
### Documentation
184+
Documentation
185+
-------------
145186

146187
You can get additional information including the tutorial on the
147188
[wiki](https://github.com/msgpack/msgpack-c/wiki).

0 commit comments

Comments
 (0)