Skip to content

Commit af68bf3

Browse files
3p3rdarrachequesne
authored andcommitted
refactor: remove Boost dependency (#176)
- add the standalone ASIO as a replacement for Boost ASIO - add Catch++ as a replacement for Boost Test framework - remove dependency on Boost DateTime and Boost Lexical Cast
1 parent 6063cb1 commit af68bf3

16 files changed

+250
-288
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
[submodule "lib/rapidjson"]
55
path = lib/rapidjson
66
url = https://github.com/miloyip/rapidjson.git
7+
[submodule "lib/asio"]
8+
path = lib/asio
9+
url = https://github.com/chriskohlhoff/asio.git
10+
[submodule "lib/catch"]
11+
path = lib/catch
12+
url = https://github.com/philsquared/Catch.git

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ compiler:
55

66
before_install:
77
- sudo apt-get install clang git libssl-dev
8-
- sudo add-apt-repository -y ppa:boost-latest/ppa
98
- sudo add-apt-repository -y ppa:kubuntu-ppa/backports
109
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test -y
1110
- sudo apt-get update -yqq
12-
- sudo apt-get install -y libboost1.55-dev libboost-system1.55-dev libboost-date-time1.55-dev libboost-random1.55-dev
1311
- sudo apt-get install -y cmake g++-4.8
1412
- sed -i -e 's/cmake_minimum_required(VERSION 3.1.0/cmake_minimum_required(VERSION 2.8.12/' ./CMakeLists.txt
1513
script:
16-
- cmake -D CMAKE_CXX_FLAGS=-std=c++11 .
14+
- cmake -D CMAKE_CXX_FLAGS=-std=c++11 -D BUILD_UNIT_TESTS=ON .
1715
- make
16+
- make test
1817
- make install

BOOST.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
22
PROJECT(sioclient)
33

44
option(BUILD_SHARED_LIBS "Build the shared library" OFF)
5-
option(Boost_USE_STATIC_LIBS "Use Boost static version" ON)
5+
option(BUILD_UNIT_TESTS "Builds unit tests target" OFF)
66

77
set(MAJOR 1)
88
set(MINOR 6)
@@ -16,27 +16,32 @@ MESSAGE(SEND_ERROR "CMAKE_BUILD_TYPE must be either Release or Debug")
1616
return()
1717
endif()
1818

19-
set(BOOST_VER "1.55.0" CACHE STRING "boost version" )
20-
21-
set(Boost_USE_MULTITHREADED ON)
22-
set(Boost_USE_STATIC_RUNTIME OFF)
23-
find_package(Boost ${BOOST_VER} REQUIRED COMPONENTS system date_time random)
24-
2519
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src ALL_SRC)
2620
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/internal ALL_SRC)
2721
file(GLOB ALL_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.h )
2822
set(SIO_INCLUDEDIR ${CMAKE_CURRENT_LIST_DIR})
2923

24+
add_definitions(
25+
# These will force ASIO to compile without Boost
26+
-DBOOST_DATE_TIME_NO_LIB
27+
-DBOOST_REGEX_NO_LIB
28+
-DASIO_STANDALONE
29+
# These will force WebsocketPP to compile with C++11
30+
-D_WEBSOCKETPP_CPP11_STL_
31+
-D_WEBSOCKETPP_CPP11_FUNCTIONAL_
32+
)
33+
3034
add_library(sioclient ${ALL_SRC})
31-
target_include_directories(sioclient PRIVATE ${Boost_INCLUDE_DIRS}
35+
target_include_directories(sioclient PRIVATE
3236
${CMAKE_CURRENT_LIST_DIR}/src
3337
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
3438
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
39+
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
3540
)
3641

3742
set_property(TARGET sioclient PROPERTY CXX_STANDARD 11)
3843
set_property(TARGET sioclient PROPERTY CXX_STANDARD_REQUIRED ON)
39-
target_link_libraries(sioclient PRIVATE ${Boost_LIBRARIES})
44+
4045
if(BUILD_SHARED_LIBS)
4146
set_target_properties(sioclient
4247
PROPERTIES
@@ -49,16 +54,17 @@ list(APPEND TARGET_LIBRARIES sioclient)
4954
find_package(OpenSSL)
5055
if(OPENSSL_FOUND)
5156
add_library(sioclient_tls ${ALL_SRC})
52-
target_include_directories(sioclient_tls PRIVATE ${Boost_INCLUDE_DIRS}
57+
target_include_directories(sioclient_tls PRIVATE
5358
${CMAKE_CURRENT_LIST_DIR}/src
5459
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
5560
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
61+
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
5662
${OPENSSL_INCLUDE_DIR}
5763
)
5864

5965
set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD 11)
6066
set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD_REQUIRED ON)
61-
target_link_libraries(sioclient_tls PRIVATE ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} )
67+
target_link_libraries(sioclient_tls PRIVATE ${OPENSSL_LIBRARIES} )
6268
target_compile_definitions(sioclient_tls PRIVATE -DSIO_TLS)
6369
if(BUILD_SHARED_LIBS)
6470
set_target_properties(sioclient_tls
@@ -79,6 +85,8 @@ install(TARGETS ${TARGET_LIBRARIES}
7985
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}"
8086
)
8187

82-
install(FILES ${Boost_LIBRARIES}
83-
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}"
84-
)
88+
if(BUILD_UNIT_TESTS)
89+
message(STATUS "Building with unit test support.")
90+
enable_testing()
91+
add_subdirectory(test)
92+
endif()

INSTALL.md

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,13 @@
11
## Install
22

33
### With CMake
4-
1. Install boost, see [Boost setup](#boost_setup) section.
5-
2. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
6-
3. Run `cmake -DBOOST_ROOT:STRING=<your boost install folder> -DBOOST_VER:STRING=<your boost version> ./`
7-
4. Run `make install`(if makefile generated) or open generated project (if project file generated) to build.
8-
5. Outputs is under `./build`, link with the all static libs under `./build/lib` and include headers under `./build/include` in your client code where you want to use it.
9-
10-
* If you're using boost without install,you can specify `boost include dir` and `boost lib dir` separately by:
11-
```bash
12-
cmake
13-
-DBOOST_INCLUDEDIR=<your boost include folder>
14-
-DBOOST_LIBRARYDIR=<your boost lib folder>
15-
-DBOOST_VER:STRING=<your boost version>
16-
./
17-
```
18-
* CMake didn't allow merging static libraries,but they're all copied to `./build/lib`, you can DIY if you like.
4+
1. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
5+
2. Run `cmake ./`
6+
3. Run `make install`(if makefile generated) or open generated project (if project file generated) to build.
7+
4. Outputs is under `./build`, link with the all static libs under `./build/lib` and include headers under `./build/include` in your client code where you want to use it.
198

209
### Without CMake
21-
1. Install boost, see [Boost setup](#boost_setup) section.
22-
2. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
23-
3. Add `<your boost install folder>/include`,`./lib/websocketpp` and `./lib/rapidjson/include` to headers search path.
24-
4. Include all files under `./src` in your project, add `sio_client.cpp`,`sio_socket.cpp`,`internal/sio_client_impl.cpp`, `internal/sio_packet.cpp` to source list.
25-
5. Add `<your boost install folder>/lib` to library search path, add `boost.lib`(Win32) or `-lboost`(Other) link option.
26-
6. Include `sio_client.h` in your client code where you want to use it.
27-
28-
## Boost setup
29-
30-
1. Download boost from [boost.org](http://www.boost.org/).
31-
1. Unpack boost to some place.
32-
1. Run either .\bootstrap.bat (on Windows), or ./bootstrap.sh (on other operating systems) under boost folder.
33-
34-
## Boost build (Build the necessary subset only)
35-
Windows (or other mainstream desktop platforms shall work too):
36-
37-
The following script will build the necessary subset:
38-
39-
```bash
40-
bjam install --prefix="<your boost install folder>" --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi
41-
```
42-
Optionally You can merge all output .lib files into a fat one, especially if you're not using cmake.
43-
44-
In output folder, run:
45-
46-
```bash
47-
lib.exe /OUT:boost.lib *
48-
```
10+
1. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
11+
2. Add `./lib/asio/asio/include`, `./lib/websocketpp` and `./lib/rapidjson/include` to headers search path.
12+
3. Include all files under `./src` in your project, add `sio_client.cpp`,`sio_socket.cpp`,`internal/sio_client_impl.cpp`, `internal/sio_packet.cpp` to source list.
13+
4. Include `sio_client.h` in your client code where you want to use it.

lib/asio

Submodule asio added at 230c0d2

lib/catch

Submodule catch added at 9c07718

lib/websocketpp

Submodule websocketpp updated 139 files

0 commit comments

Comments
 (0)