Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build on some compilers #240

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
877f235
checked in ASIO standalone as a replacement for Boost
3p3r Sep 10, 2017
cce6d86
upgraded websocketpp to tag 0.7.0
3p3r Sep 10, 2017
4a44d6d
removed boost from the top level cmake file
3p3r Sep 10, 2017
cc53a6f
removed boost from sio_client_impl
3p3r Sep 10, 2017
573f10e
removed boost from sio_packet
3p3r Sep 10, 2017
6ba9c9c
removed boost from sio_client
3p3r Sep 10, 2017
fbc429e
Added Catch++ as a replacement for Boost Test
3p3r Sep 10, 2017
51c1bba
removed boost from unit tests
3p3r Sep 10, 2017
7bfaaf3
removed Boost from docs
3p3r Sep 10, 2017
4dd6afd
avoid installing boost on Travis
3p3r Sep 10, 2017
13fdb7a
integrated unit tests with CTest so it can be executed normally on Tr…
3p3r Sep 10, 2017
c300bc8
fixed invalid calls to CHECK for non-windows platforms
3p3r Sep 10, 2017
ab62b31
fix build on some compilers
kusharami Oct 30, 2019
85c92f2
Merge branch 'no-boost'
kusharami Oct 30, 2019
8565278
fix release version LOG
kusharami Nov 8, 2019
a41c944
fix release version LOG
kusharami Nov 8, 2019
cb7e1f0
use original rapidjson v1.1.0
Dec 23, 2020
9d6e6c9
use websocketpp v0.8.2
Dec 23, 2020
7771ecc
added qmake project files
kusharami Mar 16, 2021
48f3953
[qmake] fix SOCKET_IO_CLIENT_ROOT
kusharami Mar 16, 2021
7036bfd
refactor: use correct Engine.IO protocol revision
darrachequesne Jan 9, 2021
cd451e0
support both TLS and non TLS connections, if server url hashttps or w…
kusharami Jul 15, 2021
e8f6c5d
save sio::client configuration in sio::client::connect
kusharami Jul 16, 2021
e632252
Merge branch 'feature/support_both_tls_and_non_tls' into develop
kusharami Jul 16, 2021
4bba449
support mingw32 clang
kusharami Mar 30, 2022
72b2d3e
support TLS v1.2
acherdantseva May 22, 2023
b3d6de6
mac support arm64 and universal builds
kusharami Jan 23, 2024
747ba1b
fix warnings
kusharami Jan 31, 2024
103c9b5
move headers
kusharami Apr 26, 2024
668cc86
fix crash on client destruction
kusharami Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
**/*.user
bin*/
**/*.user
8 changes: 7 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
url = https://github.com/zaphoyd/websocketpp.git
[submodule "lib/rapidjson"]
path = lib/rapidjson
url = https://github.com/miloyip/rapidjson.git
url = https://github.com/Tencent/rapidjson.git
[submodule "lib/asio"]
path = lib/asio
url = https://github.com/chriskohlhoff/asio.git
[submodule "lib/catch"]
path = lib/catch
url = https://github.com/philsquared/Catch.git
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ compiler:

before_install:
- sudo apt-get install clang git libssl-dev
- sudo add-apt-repository -y ppa:boost-latest/ppa
- sudo add-apt-repository -y ppa:kubuntu-ppa/backports
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test -y
- sudo apt-get update -yqq
- sudo apt-get install -y libboost1.55-dev libboost-system1.55-dev libboost-date-time1.55-dev libboost-random1.55-dev
- sudo apt-get install -y cmake g++-4.8
- sed -i -e 's/cmake_minimum_required(VERSION 3.1.0/cmake_minimum_required(VERSION 2.8.12/' ./CMakeLists.txt
script:
- cmake -D CMAKE_CXX_FLAGS=-std=c++11 .
- cmake -D CMAKE_CXX_FLAGS=-std=c++11 -D BUILD_UNIT_TESTS=ON .
- make
- make test
- make install
21 changes: 0 additions & 21 deletions BOOST.md

This file was deleted.

36 changes: 22 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
PROJECT(sioclient)

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

set(MAJOR 1)
set(MINOR 6)
Expand All @@ -16,27 +16,32 @@ MESSAGE(SEND_ERROR "CMAKE_BUILD_TYPE must be either Release or Debug")
return()
endif()

set(BOOST_VER "1.55.0" CACHE STRING "boost version" )

set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost ${BOOST_VER} REQUIRED COMPONENTS system date_time random)

aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src ALL_SRC)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/internal ALL_SRC)
file(GLOB ALL_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.h )
set(SIO_INCLUDEDIR ${CMAKE_CURRENT_LIST_DIR})

add_definitions(
# These will force ASIO to compile without Boost
-DBOOST_DATE_TIME_NO_LIB
-DBOOST_REGEX_NO_LIB
-DASIO_STANDALONE
# These will force WebsocketPP to compile with C++11
-D_WEBSOCKETPP_CPP11_STL_
-D_WEBSOCKETPP_CPP11_FUNCTIONAL_
)

add_library(sioclient ${ALL_SRC})
target_include_directories(sioclient PRIVATE ${Boost_INCLUDE_DIRS}
target_include_directories(sioclient PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
)

set_property(TARGET sioclient PROPERTY CXX_STANDARD 11)
set_property(TARGET sioclient PROPERTY CXX_STANDARD_REQUIRED ON)
target_link_libraries(sioclient PRIVATE ${Boost_LIBRARIES})

if(BUILD_SHARED_LIBS)
set_target_properties(sioclient
PROPERTIES
Expand All @@ -49,16 +54,17 @@ list(APPEND TARGET_LIBRARIES sioclient)
find_package(OpenSSL)
if(OPENSSL_FOUND)
add_library(sioclient_tls ${ALL_SRC})
target_include_directories(sioclient_tls PRIVATE ${Boost_INCLUDE_DIRS}
target_include_directories(sioclient_tls PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
${OPENSSL_INCLUDE_DIR}
)

set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD 11)
set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD_REQUIRED ON)
target_link_libraries(sioclient_tls PRIVATE ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} )
target_link_libraries(sioclient_tls PRIVATE ${OPENSSL_LIBRARIES} )
target_compile_definitions(sioclient_tls PRIVATE -DSIO_TLS)
if(BUILD_SHARED_LIBS)
set_target_properties(sioclient_tls
Expand All @@ -79,6 +85,8 @@ install(TARGETS ${TARGET_LIBRARIES}
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}"
)

install(FILES ${Boost_LIBRARIES}
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}"
)
if(BUILD_UNIT_TESTS)
message(STATUS "Building with unit test support.")
enable_testing()
add_subdirectory(test)
endif()
51 changes: 8 additions & 43 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,13 @@
## Install

### With CMake
1. Install boost, see [Boost setup](#boost_setup) section.
2. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
3. Run `cmake -DBOOST_ROOT:STRING=<your boost install folder> -DBOOST_VER:STRING=<your boost version> ./`
4. Run `make install`(if makefile generated) or open generated project (if project file generated) to build.
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.

* If you're using boost without install,you can specify `boost include dir` and `boost lib dir` separately by:
```bash
cmake
-DBOOST_INCLUDEDIR=<your boost include folder>
-DBOOST_LIBRARYDIR=<your boost lib folder>
-DBOOST_VER:STRING=<your boost version>
./
```
* CMake didn't allow merging static libraries,but they're all copied to `./build/lib`, you can DIY if you like.
1. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
2. Run `cmake ./`
3. Run `make install`(if makefile generated) or open generated project (if project file generated) to build.
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.

### Without CMake
1. Install boost, see [Boost setup](#boost_setup) section.
2. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
3. Add `<your boost install folder>/include`,`./lib/websocketpp` and `./lib/rapidjson/include` to headers search path.
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.
5. Add `<your boost install folder>/lib` to library search path, add `boost.lib`(Win32) or `-lboost`(Other) link option.
6. Include `sio_client.h` in your client code where you want to use it.

## Boost setup

1. Download boost from [boost.org](http://www.boost.org/).
1. Unpack boost to some place.
1. Run either .\bootstrap.bat (on Windows), or ./bootstrap.sh (on other operating systems) under boost folder.

## Boost build (Build the necessary subset only)
Windows (or other mainstream desktop platforms shall work too):

The following script will build the necessary subset:

```bash
bjam install --prefix="<your boost install folder>" --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi
```
Optionally You can merge all output .lib files into a fat one, especially if you're not using cmake.

In output folder, run:

```bash
lib.exe /OUT:boost.lib *
```
1. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
2. Add `./lib/asio/asio/include`, `./lib/websocketpp` and `./lib/rapidjson/include` to headers search path.
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.
4. Include `sio_client.h` in your client code where you want to use it.
1 change: 1 addition & 0 deletions lib/asio
Submodule asio added at 230c0d
1 change: 1 addition & 0 deletions lib/catch
Submodule catch added at 9c0771
2 changes: 1 addition & 1 deletion lib/rapidjson
Submodule rapidjson updated 224 files
2 changes: 1 addition & 1 deletion lib/websocketpp
Submodule websocketpp updated 166 files
28 changes: 28 additions & 0 deletions socket.io-client-depend.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
include(socket.io-client.pri)

msvc {
PRE_TARGETDEPS += $$SOCKET_IO_CLIENT_BIN/socket.io-client.lib
} else {
PRE_TARGETDEPS += $$SOCKET_IO_CLIENT_BIN/libsocket.io-client.a
}

LIBS += -L$$SOCKET_IO_CLIENT_BIN
LIBS += -lsocket.io-client

!isEmpty(USE_SYSTEM_OPENSSL) {
LIBS += -lcrypto -lssl
} else:!isEmpty(OPENSSL_INCLUDE_DIR):!isEmpty(OPENSSL_LIB_DIR) {
LIBS += -L$$OPENSSL_LIB_DIR

msvc {
LIBS += -llibcrypto -llibssl
PRE_TARGETDEPS += \
$$OPENSSL_LIB_DIR/libcrypto.lib \
$$OPENSSL_LIB_DIR/libssl.lib
} else {
LIBS += -lcrypto -lssl
PRE_TARGETDEPS += \
$$OPENSSL_LIB_DIR/libcrypto.a \
$$OPENSSL_LIB_DIR/libssl.a
}
}
70 changes: 70 additions & 0 deletions socket.io-client.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
SOCKET_IO_CLIENT_ROOT = $$PWD
SOCKET_IO_CLIENT_SRC = $$SOCKET_IO_CLIENT_ROOT/src
SOCKET_IO_CLIENT_BIN = $$PWD/bin
SOCKET_IO_CLIENT_DEPEND = $$SOCKET_IO_CLIENT_ROOT/lib

msvc {
lessThan(QMAKE_MSC_VER, 1900) {
DEFINES += _WEBSOCKETPP_NOEXCEPT_TOKEN_=_NOEXCEPT
} else {
DEFINES += _WEBSOCKETPP_NOEXCEPT_TOKEN_=noexcept
}
QMAKE_CXXFLAGS += /wd4503
} else {
DEFINES += _WEBSOCKETPP_NOEXCEPT_TOKEN_=noexcept
}

win32 {
DEFINES += _WINSOCK_DEPRECATED_NO_WARNINGS
} else {
DEFINES += _WEBSOCKETPP_CPP11_THREAD_
}

OPENSSL_INCLUDE_DIR = $$(OPENSSL_INCLUDE_DIR)
OPENSSL_LIB_DIR = $$(OPENSSL_LIB_DIR)
USE_SYSTEM_OPENSSL = $$(USE_SYSTEM_OPENSSL)

DEFINES += ASIO_STANDALONE
DEFINES += _WEBSOCKETPP_CPP11_TYPE_TRAITS_
DEFINES += _WEBSOCKETPP_CPP11_MEMORY_
DEFINES += _WEBSOCKETPP_CPP11_FUNCTIONAL_
DEFINES += _WEBSOCKETPP_CPP11_CHRONO_
DEFINES += _WEBSOCKETPP_CPP11_RANDOM_DEVICE_
DEFINES += _WEBSOCKETPP_CPP11_REGEX_
DEFINES += _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
DEFINES += _WEBSOCKETPP_INITIALIZER_LISTS_
DEFINES += _WEBSOCKETPP_CONSTEXPR_TOKEN_=
DEFINES += RAPIDJSON_HAS_CXX11_RVALUE_REFS=1

macx:SOCKET_IO_CLIENT_BIN = $$SOCKET_IO_CLIENT_BIN-macx
linux:SOCKET_IO_CLIENT_BIN = $$SOCKET_IO_CLIENT_BIN-linux
win32 {
SOCKET_IO_CLIENT_BIN = $$SOCKET_IO_CLIENT_BIN-win32
msvc:SOCKET_IO_CLIENT_BIN = $$SOCKET_IO_CLIENT_BIN-msvc
}
clang:SOCKET_IO_CLIENT_BIN = $$SOCKET_IO_CLIENT_BIN-clang
else::gcc:SOCKET_IO_CLIENT_BIN = $$SOCKET_IO_CLIENT_BIN-gcc

ARCH = $$QT_ARCH
macx {
isEqual(QMAKE_APPLE_DEVICE_ARCHS, "x86_64") {
ARCH = $$QMAKE_APPLE_DEVICE_ARCHS
} else:isEqual(QMAKE_APPLE_DEVICE_ARCHS, "arm64") {
ARCH = $$QMAKE_APPLE_DEVICE_ARCHS
} else:contains(QMAKE_APPLE_DEVICE_ARCHS, "x86_64"):contains(QMAKE_APPLE_DEVICE_ARCHS, "arm64") {
ARCH = "universal"
}
}

SOCKET_IO_CLIENT_BIN = $$SOCKET_IO_CLIENT_BIN-$$ARCH

CONFIG(debug, debug|release) {
SOCKET_IO_CLIENT_BIN = $$SOCKET_IO_CLIENT_BIN/debug
}

INCLUDEPATH += \
$$SOCKET_IO_CLIENT_SRC \
$$SOCKET_IO_CLIENT_DEPEND/asio/asio/include \
$$SOCKET_IO_CLIENT_DEPEND/catch/single_include \
$$SOCKET_IO_CLIENT_DEPEND/rapidjson/include \
$$SOCKET_IO_CLIENT_DEPEND/websocketpp
52 changes: 52 additions & 0 deletions socket.io-client.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
CONFIG -= qt

TARGET = socket.io-client

TEMPLATE = lib
CONFIG += staticlib

include(socket.io-client.pri)

!isEmpty(USE_SYSTEM_OPENSSL) {
DEFINES += HAVE_OPENSSL
} else:!isEmpty(OPENSSL_INCLUDE_DIR):!isEmpty(OPENSSL_LIB_DIR) {
DEFINES += HAVE_OPENSSL
INCLUDEPATH += $$OPENSSL_INCLUDE_DIR
}

CONFIG += c++11

msvc {
QMAKE_CXXFLAGS_WARN_ON += /wd4267
DEFINES += _CRT_SECURE_NO_WARNINGS
DEFINES += _SCL_SECURE_NO_WARNINGS
} else:clang|gcc {
QMAKE_CXXFLAGS_WARN_ON += \
-Wno-null-pointer-subtraction \
-Wno-deprecated-declarations \
-Wno-unknown-warning-option \
-Wno-unknown-warning \
-Wno-unused-command-line-argument
}

CONFIG(debug, debug|release) {
DEFINES += DEBUG=1
} else {
DEFINES += NDEBUG
}

HEADERS += \
$$SOCKET_IO_CLIENT_SRC/sio_client.h \
$$SOCKET_IO_CLIENT_SRC/sio_message.h \
$$SOCKET_IO_CLIENT_SRC/sio_socket.h \
$$SOCKET_IO_CLIENT_SRC/internal/sio_client_config.h \
$$SOCKET_IO_CLIENT_SRC/internal/sio_client_impl.h \
$$SOCKET_IO_CLIENT_SRC/internal/sio_packet.h

SOURCES += \
$$SOCKET_IO_CLIENT_SRC/sio_client.cpp \
$$SOCKET_IO_CLIENT_SRC/sio_socket.cpp \
$$SOCKET_IO_CLIENT_SRC/internal/sio_client_impl.cpp \
$$SOCKET_IO_CLIENT_SRC/internal/sio_packet.cpp

DESTDIR = $$SOCKET_IO_CLIENT_BIN
Loading