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,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

View file

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