From 328d44fbb606fbefa2fcbda14c8e01248642682f Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Sat, 21 Sep 2019 12:15:49 +0900 Subject: [PATCH] Add support for MINGW compiler --- cpp_impl/CMakeLists.txt | 10 ++++++++-- cpp_impl/src/UDPConnection.h | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cpp_impl/CMakeLists.txt b/cpp_impl/CMakeLists.txt index 0a9f675..0d8638c 100644 --- a/cpp_impl/CMakeLists.txt +++ b/cpp_impl/CMakeLists.txt @@ -30,8 +30,14 @@ set_target_properties(UDPConnection PROPERTIES VERSION ${UDPConnection_VERSION}) target_compile_features(UDPConnection PUBLIC cxx_std_17) target_link_libraries(UDPConnection PUBLIC pthread) if(WIN32) - target_link_libraries(UDPConnection PUBLIC Ws2_32) - target_link_libraries(UDPConnection PUBLIC Iphlpapi) + if(MINGW) + target_compile_definitions(UDPConnection PUBLIC UDPC_PLATFORM_MINGW) + target_link_libraries(UDPConnection PUBLIC ws2_32) + target_link_libraries(UDPConnection PUBLIC iphlpapi) + else() + target_link_libraries(UDPConnection PUBLIC Ws2_32) + target_link_libraries(UDPConnection PUBLIC Iphlpapi) + endif() endif() target_include_directories(UDPConnection PUBLIC diff --git a/cpp_impl/src/UDPConnection.h b/cpp_impl/src/UDPConnection.h index 3d24e02..d0dbedb 100644 --- a/cpp_impl/src/UDPConnection.h +++ b/cpp_impl/src/UDPConnection.h @@ -20,8 +20,13 @@ // OS-based networking macros #if UDPC_PLATFORM == UDPC_PLATFORM_WINDOWS #include -#include -#include +# ifdef UDPC_PLATFORM_MINGW +# include +# include +# else +# include +# include +# endif #define UDPC_CLEANUPSOCKET(x) closesocket(x) #define UDPC_SOCKETTYPE SOCKET