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

add support for mingw-std-threads #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ target_include_directories(sioclient PRIVATE ${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
)

if(MINGW_STD_THREADS)
target_include_directories(sioclient PRIVATE ${MINGW_STD_THREADS})
target_compile_definitions(sioclient PRIVATE -D_USE_MINGW_STD_THREADS -D_WEBSOCKETPP_NO_CPP11_THREAD_)
endif()

set_property(TARGET sioclient PROPERTY CXX_STANDARD 11)
set_property(TARGET sioclient PROPERTY CXX_STANDARD_REQUIRED ON)
target_link_libraries(sioclient PRIVATE ${Boost_LIBRARIES})
Expand All @@ -56,6 +61,11 @@ target_include_directories(sioclient_tls PRIVATE ${Boost_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
)

if(MINGW_STD_THREADS)
target_include_directories(sioclient_tls PRIVATE ${MINGW_STD_THREADS})
target_compile_definitions(sioclient_tls PRIVATE -D_USE_MINGW_STD_THREADS -D_WEBSOCKETPP_NO_CPP11_THREAD_)
endif()

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} )
Expand Down
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cmake
./
```
* CMake didn't allow merging static libraries,but they're all copied to `./build/lib`, you can DIY if you like.
* If you are compiling with MinGW, you might need to use [mingw-std-threads](https://github.com/meganz/mingw-std-threads). Use `-DMINGW_STD_THREADS=<path to mingw-std-threads>` to enable.

### Without CMake
1. Install boost, see [Boost setup](#boost_setup) section.
Expand Down
7 changes: 7 additions & 0 deletions src/internal/sio_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

#include <cstdint>
#ifdef _WIN32
#ifndef _USE_MINGW_STD_THREADS
#define _WEBSOCKETPP_CPP11_THREAD_
#endif
#define BOOST_ALL_NO_LIB
//#define _WEBSOCKETPP_CPP11_RANDOM_DEVICE_
#define _WEBSOCKETPP_NO_CPP11_FUNCTIONAL_
Expand Down Expand Up @@ -35,6 +37,11 @@ typedef websocketpp::config::asio_client client_config;
#include <memory>
#include <map>
#include <thread>
#include <mutex>
#ifdef _USE_MINGW_STD_THREADS
#include "mingw.thread.h"
#include "mingw.mutex.h"
#endif
#include "../sio_client.h"
#include "sio_packet.h"

Expand Down