mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-08-29 05:21:17 +00:00
Fixed build issue with MinGW (#64)
This commit is contained in:
+10
-2
@@ -8,8 +8,13 @@ option(USE_MBEDTLS "Use MbedTLS instead of OpenSSL" OFF)
|
|||||||
|
|
||||||
SET(CMAKE_C_STANDARD 11)
|
SET(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE_BACKUP ${CMAKE_POSITION_INDEPENDENT_CODE})
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
add_subdirectory(enet)
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE_BACKUP})
|
||||||
|
unset(CMAKE_POSITION_INDEPENDENT_CODE_BACKUP)
|
||||||
|
|
||||||
aux_source_directory(src SRC_LIST)
|
aux_source_directory(src SRC_LIST)
|
||||||
aux_source_directory(enet SRC_LIST)
|
|
||||||
aux_source_directory(reedsolomon SRC_LIST)
|
aux_source_directory(reedsolomon SRC_LIST)
|
||||||
|
|
||||||
# Build shared library by default, but allows user override
|
# Build shared library by default, but allows user override
|
||||||
@@ -25,9 +30,13 @@ if (BUILD_SHARED_LIBS_OVERRIDE)
|
|||||||
unset(BUILD_SHARED_LIBS_OVERRIDE)
|
unset(BUILD_SHARED_LIBS_OVERRIDE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(moonlight-common-c PRIVATE enet)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(moonlight-common-c PRIVATE /W3 /wd4100 /wd4232 /wd5105 /WX)
|
target_compile_options(moonlight-common-c PRIVATE /W3 /wd4100 /wd4232 /wd5105 /WX)
|
||||||
target_link_libraries(moonlight-common-c PRIVATE ws2_32.lib winmm.lib)
|
target_link_libraries(moonlight-common-c PRIVATE ws2_32.lib winmm.lib)
|
||||||
|
elseif(MINGW)
|
||||||
|
target_link_libraries(moonlight-common-c PRIVATE -lws2_32 -lwinmm)
|
||||||
else()
|
else()
|
||||||
target_compile_options(moonlight-common-c PRIVATE -Wall -Wextra -Wno-unused-parameter -Werror)
|
target_compile_options(moonlight-common-c PRIVATE -Wall -Wextra -Wno-unused-parameter -Werror)
|
||||||
endif()
|
endif()
|
||||||
@@ -64,7 +73,6 @@ endif()
|
|||||||
target_include_directories(moonlight-common-c SYSTEM PUBLIC src)
|
target_include_directories(moonlight-common-c SYSTEM PUBLIC src)
|
||||||
|
|
||||||
target_include_directories(moonlight-common-c PRIVATE
|
target_include_directories(moonlight-common-c PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/enet/include
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/reedsolomon
|
${CMAKE_CURRENT_SOURCE_DIR}/reedsolomon
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule enet updated: 8d69c5abe4...9868a2653f
@@ -23,6 +23,10 @@ DWORD (WINAPI *pfnWlanEnumInterfaces)(HANDLE hClientHandle, PVOID pReserved, PWL
|
|||||||
VOID (WINAPI *pfnWlanFreeMemory)(PVOID pMemory);
|
VOID (WINAPI *pfnWlanFreeMemory)(PVOID pMemory);
|
||||||
DWORD (WINAPI *pfnWlanSetInterface)(HANDLE hClientHandle, CONST GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, DWORD dwDataSize, CONST PVOID pData, PVOID pReserved);
|
DWORD (WINAPI *pfnWlanSetInterface)(HANDLE hClientHandle, CONST GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, DWORD dwDataSize, CONST PVOID pData, PVOID pReserved);
|
||||||
|
|
||||||
|
#ifndef WLAN_API_MAKE_VERSION
|
||||||
|
#define WLAN_API_MAKE_VERSION(_major, _minor) (((DWORD)(_minor)) << 16 | (_major))
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void addrToUrlSafeString(struct sockaddr_storage* addr, char* string)
|
void addrToUrlSafeString(struct sockaddr_storage* addr, char* string)
|
||||||
@@ -302,7 +306,11 @@ int setSocketNonBlocking(SOCKET s, bool enabled) {
|
|||||||
#elif defined(O_NONBLOCK)
|
#elif defined(O_NONBLOCK)
|
||||||
return fcntl(s, F_SETFL, (enabled ? O_NONBLOCK : 0) | (fcntl(s, F_GETFL) & ~O_NONBLOCK));
|
return fcntl(s, F_SETFL, (enabled ? O_NONBLOCK : 0) | (fcntl(s, F_GETFL) & ~O_NONBLOCK));
|
||||||
#elif defined(FIONBIO)
|
#elif defined(FIONBIO)
|
||||||
|
#ifdef LC_WINDOWS
|
||||||
|
u_long val = enabled ? 1 : 0;
|
||||||
|
#else
|
||||||
int val = enabled ? 1 : 0;
|
int val = enabled ? 1 : 0;
|
||||||
|
#endif
|
||||||
return ioctlsocket(s, FIONBIO, &val);
|
return ioctlsocket(s, FIONBIO, &val);
|
||||||
#else
|
#else
|
||||||
#error Please define your platform non-blocking sockets API!
|
#error Please define your platform non-blocking sockets API!
|
||||||
|
|||||||
@@ -7,7 +7,11 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <wlanapi.h>
|
#include <wlanapi.h>
|
||||||
|
#ifndef __MINGW32__
|
||||||
#include <timeapi.h>
|
#include <timeapi.h>
|
||||||
|
#else
|
||||||
|
#include <mmsystem.h>
|
||||||
|
#endif
|
||||||
#define SetLastSocketError(x) WSASetLastError(x)
|
#define SetLastSocketError(x) WSASetLastError(x)
|
||||||
#define LastSocketError() WSAGetLastError()
|
#define LastSocketError() WSAGetLastError()
|
||||||
|
|
||||||
@@ -23,6 +27,13 @@
|
|||||||
#endif
|
#endif
|
||||||
#define EINTR WSAEINTR
|
#define EINTR WSAEINTR
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#undef EWOULDBLOCK
|
||||||
|
#undef EINPROGRESS
|
||||||
|
#undef ETIMEDOUT
|
||||||
|
#undef ECONNREFUSED
|
||||||
|
#endif
|
||||||
|
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
#define EINPROGRESS WSAEINPROGRESS
|
#define EINPROGRESS WSAEINPROGRESS
|
||||||
#define ETIMEDOUT WSAETIMEDOUT
|
#define ETIMEDOUT WSAETIMEDOUT
|
||||||
|
|||||||
Reference in New Issue
Block a user