Skip to content

Commit 89b477e

Browse files
committed
readme completed
1 parent 2c9ae96 commit 89b477e

File tree

1 file changed

+99
-6
lines changed

1 file changed

+99
-6
lines changed

README.md

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,102 @@
1-
# boost-lib
2-
Boost dependency manager for CMake.js based native modules
1+
# boost-lib (MIT)
32

4-
Requires:
3+
# About
54

6-
- CMake
7-
- Git
5+
boos-lib is a [Boost](http://www.boost.org/) dependency manager for [CMake.js](https://www.npmjs.com/package/cmake-js) based native modules.
86

9-
In progress. Gonna be cool.
7+
Everyone knowns about [Boost](http://www.boost.org/). It's the base of almost all C++ projects out there. But using it in native node addons was not so easy (until now). It's a huge download that can be accessible by navigating through the infamous Sourceforge Crapware Screens. After downloading, you will get the source files, bundled with Jam based build system that is impossible to integrate with node-gyp.
8+
9+
So, if you wanted to create a native node module with Boost dependency, then you had the only option that to write down somewhere in the readme that your module requires Boost 1.x, and that's it. Your module consumers had to install Boost 1.x, compile it, set some environment variables pointing to their installation, and hope for that works with your module. There is not a miracle that there is no Boost based native node module exists ... yet.
10+
11+
The good news there is hope. With CMake.js you can create native modules with Boost dependency. If your module consumer has the appropriate Boost version installed, then your module will use that. If not, then boost-lib module downloads Boost from Github, compiles the required libraries (only the required ones), and your module will use that installation. Everything is automatic and as fast as possible. A typical Boost installation with one required library takes about ~1.5 minutes, and that has to be done only once, any following module installations will use that deployment.
12+
13+
#### CMake.js
14+
15+
CMake.js is a Node.js/io.js native addon build tool which works exactly like node-gyp, but instead of gyp, it is based on [CMake build system](http://cmake.org). It's [on the npm](https://www.npmjs.com/package/cmake-js).
16+
17+
# Installation
18+
19+
```
20+
npm install boost-lib
21+
```
22+
23+
# Usage
24+
25+
In a nutshell. *(For more complete documentation please see [the tutorial](https://github.com/unbornchikken/cmake-js/wiki/TUTORIAL-04-Creating-CMake.js-based-native-modules-with-Boost-dependency).)*
26+
27+
## 1. Include
28+
29+
Install boost-lib module from npm.
30+
31+
```
32+
npm install boost-lib --save
33+
```
34+
35+
Enter the following into your project's root CMakeLists.txt file to include BoostLib CMake module:
36+
37+
```cmake
38+
# Include BoostLib module
39+
SET(CMAKE_MODULE_PATH
40+
"${CMAKE_CURRENT_SOURCE_DIR}/node_modules/boost-lib/cmake")
41+
42+
include(BoostLib)
43+
```
44+
45+
## 2. Require
46+
47+
This makes `require_boost_libs` function available. It has two arguments:
48+
49+
- in the first argument you have to specify required Boost library's semver specification like that you can use in package.json. For example to use Boost 1.58, enter `1.58.0`, to use Boost 1.57 or above, enter `">= 1.57.0"`. See [semver](https://www.npmjs.com/package/semver) modules's documentation for further details.
50+
- in the second argument you can specify required Boost's to-be-compiled libraries separated by semicolon. Leave blank if you need header only libraries. For example to depend on Boost.coroutine and Boost.DateTime, enter `coroutine;date_time`.
51+
52+
Examples:
53+
54+
Boost 1.57 or above required with thread and context libraries:
55+
56+
```cmake
57+
require_boost_libs(">= 1.57.0" thread;context)
58+
```
59+
60+
Boost 1.58 required with header only libraries:
61+
62+
```cmake
63+
require_boost_libs(1.57.0 "")
64+
```
65+
66+
Known to-be-build Boost libraries so far:
67+
68+
- chrono
69+
- coroutine
70+
- context
71+
- filesystem
72+
- graph
73+
- locale
74+
- log
75+
- system
76+
- thread
77+
- timer
78+
- wave
79+
80+
Their internal dependencies are handled automatically. So if you're requireing coroutine which depends on context and system, you don't have to sepcify them all, only coroutine.
81+
82+
## 3. Use
83+
84+
After Boost's include path should be regitered by entering:
85+
86+
```cmake
87+
include_directories(${Boost_INCLUDE_DIRS})
88+
```
89+
90+
And you have to link your addon aggainst Boost libraries:
91+
92+
```cmake
93+
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB};${Boost_LIBRARIES})
94+
```
95+
96+
# Example and tutorial
97+
98+
The [tutorial](https://github.com/unbornchikken/cmake-js/wiki/TUTORIAL-04-Creating-CMake.js-based-native-modules-with-Boost-dependency) is about making the [example module](https://github.com/unbornchikken/cmake-js-tut-04-boost-module), which can be downloaded from there:
99+
100+
```
101+
git clone https://github.com/unbornchikken/cmake-js-tut-04-boost-module
102+
```

0 commit comments

Comments
 (0)