Add support for MINGW compiler

This commit is contained in:
Stephen Seo 2019-09-21 12:15:49 +09:00
parent aa7255c2e5
commit 328d44fbb6
2 changed files with 15 additions and 4 deletions

View file

@ -30,9 +30,15 @@ set_target_properties(UDPConnection PROPERTIES VERSION ${UDPConnection_VERSION})
target_compile_features(UDPConnection PUBLIC cxx_std_17) target_compile_features(UDPConnection PUBLIC cxx_std_17)
target_link_libraries(UDPConnection PUBLIC pthread) target_link_libraries(UDPConnection PUBLIC pthread)
if(WIN32) if(WIN32)
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 Ws2_32)
target_link_libraries(UDPConnection PUBLIC Iphlpapi) target_link_libraries(UDPConnection PUBLIC Iphlpapi)
endif() endif()
endif()
target_include_directories(UDPConnection PUBLIC target_include_directories(UDPConnection PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/RingBuffer/src") "${CMAKE_CURRENT_SOURCE_DIR}/RingBuffer/src")

View file

@ -20,8 +20,13 @@
// OS-based networking macros // OS-based networking macros
#if UDPC_PLATFORM == UDPC_PLATFORM_WINDOWS #if UDPC_PLATFORM == UDPC_PLATFORM_WINDOWS
#include <winsock2.h> #include <winsock2.h>
# ifdef UDPC_PLATFORM_MINGW
# include <ws2ipdef.h>
# include <in6addr.h>
# else
# include <Ws2ipdef.h> # include <Ws2ipdef.h>
# include <In6addr.h> # include <In6addr.h>
# endif
#define UDPC_CLEANUPSOCKET(x) closesocket(x) #define UDPC_CLEANUPSOCKET(x) closesocket(x)
#define UDPC_SOCKETTYPE SOCKET #define UDPC_SOCKETTYPE SOCKET