Sfoglia il codice sorgente

Use system installed mswsock.h if possible. Fixes build with new mingw-w64 toolchains.

ambrop7 15 anni fa
parent
commit
09694b13ba
3 ha cambiato i file con 15 aggiunte e 9 eliminazioni
  1. 9 1
      CMakeLists.txt
  2. 0 6
      misc/mswsock.h
  3. 6 2
      system/BSocket.h

+ 9 - 1
CMakeLists.txt

@@ -37,7 +37,15 @@ add_definitions(-std=gnu99 -Werror=implicit-function-declaration -Wno-unused-val
 
 # platform-specific stuff
 if (WIN32)
-    add_definitions(-DBADVPN_USE_WINAPI -D_WIN32_WINNT=0x501 -DWIN32_LEAN_AND_MEAN)
+    add_definitions(-DBADVPN_USE_WINAPI -D_WIN32_WINNT=0x600 -DWIN32_LEAN_AND_MEAN)
+
+    set(CMAKE_REQUIRED_DEFINITIONS "-D_WIN32_WINNT=0x600")
+    check_symbol_exists(WSAID_WSARECVMSG "mswsock.h" HAVE_WSARECVMSG)
+    check_symbol_exists(WSAID_WSASENDMSG "mswsock.h" HAVE_WSASENDMSG)
+    set(CMAKE_REQUIRED_DEFINITIONS "")
+    if (NOT (HAVE_WSARECVMSG AND HAVE_WSASENDMSG))
+        add_definitions(-DBADVPN_USE_CUSTOM_MSWSOCK_H)
+    endif ()
 else ()
     link_libraries(rt)
 

+ 0 - 6
misc/mswsock.h

@@ -30,10 +30,6 @@
 #ifndef BADVPN_MISC_MSWSOCK_H
 #define BADVPN_MISC_MSWSOCK_H
 
-#if !defined(__GNUC__) || defined(BADVPN_USE_SYSTEM_MSWSOCK_H)
-#include <mswsock.h>
-#else
-
 #include <windows.h>
 #include <winsock2.h>
 
@@ -85,5 +81,3 @@ typedef INT (WINAPI *LPFN_WSASENDMSG)(SOCKET s, LPWSAMSG lpMsg, DWORD dwFlags, L
     LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
 
 #endif
-
-#endif

+ 6 - 2
system/BSocket.h

@@ -29,8 +29,12 @@
 #define BADVPN_SYSTEM_BSOCKET_H
 
 #ifdef BADVPN_USE_WINAPI
-#include <winsock2.h>
-#include <misc/mswsock.h>
+    #include <winsock2.h>
+    #ifndef BADVPN_USE_CUSTOM_MSWSOCK_H
+        #include <mswsock.h>
+    #else
+        #include <misc/mswsock.h>
+    #endif
 #endif
 
 #include <misc/debug.h>