build: fix 32 bit build for Windows XP
Fix x86 32 bit build for Windows XP. Set the `WINVER` and `_WIN32_WINNT` macros to the value for Windows XP. Disable XAudio for these builds. Add the missing `inet_pton()` and `inet_ntop()` functions for SFML. Fix a FetchContent warning in the CMake as well. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
ac0dc48263
commit
3f436073be
|
@ -92,6 +92,11 @@ include(Options)
|
|||
include(Toolchain)
|
||||
include(Dependencies)
|
||||
|
||||
# We target Windows XP for 32 bit Windows builds.
|
||||
if(WIN32 AND X86)
|
||||
add_compile_definitions(-DWINVER=0x0501 -D_WIN32_WINNT=0x0501)
|
||||
endif()
|
||||
|
||||
# Disable tests when not in a git checkout.
|
||||
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
set(BUILD_TESTING OFF)
|
||||
|
|
|
@ -148,7 +148,7 @@ if(WIN32)
|
|||
option(ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" OFF)
|
||||
|
||||
set(XAUDIO2_DEFAULT ON)
|
||||
if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||
if ((MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) OR (MINGW AND X86))
|
||||
# TODO: We should update the XAudio headers to build with clang-cl. See
|
||||
# https://github.com/visualboyadvance-m/visualboyadvance-m/issues/1021
|
||||
set(XAUDIO2_DEFAULT OFF)
|
||||
|
|
|
@ -279,7 +279,7 @@ function(get_binary_packages vcpkg_exe)
|
|||
|
||||
FetchContent_GetProperties(vcpkg_binpkg)
|
||||
if(NOT vcpkg_binpkg_POPULATED)
|
||||
FetchContent_Populate(vcpkg_binpkg)
|
||||
FetchContent_MakeAvailable(vcpkg_binpkg)
|
||||
endif()
|
||||
|
||||
unset(to_install)
|
||||
|
|
|
@ -44,6 +44,63 @@ const IpAddress IpAddress::Any(0, 0, 0, 0);
|
|||
const IpAddress IpAddress::LocalHost(127, 0, 0, 1);
|
||||
const IpAddress IpAddress::Broadcast(255, 255, 255, 255);
|
||||
|
||||
// Define inet_pton() and inet_ntop() for Windows XP
|
||||
//
|
||||
// This is from:
|
||||
// https://stackoverflow.com/a/20816961/262458
|
||||
//
|
||||
#if defined(_WIN32) && _WIN32_WINNT <= _WIN32_WINNT_WINXP
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
|
||||
static int inet_pton(int af, const char *src, void *dst)
|
||||
{
|
||||
struct sockaddr_storage ss;
|
||||
int size = sizeof(ss);
|
||||
char src_copy[INET6_ADDRSTRLEN];
|
||||
|
||||
ZeroMemory(&ss, sizeof(ss));
|
||||
/* stupid non-const API */
|
||||
strncpy (src_copy, src, INET6_ADDRSTRLEN);
|
||||
src_copy[INET6_ADDRSTRLEN] = 0;
|
||||
|
||||
if (WSAStringToAddressA(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
|
||||
switch(af) {
|
||||
case AF_INET:
|
||||
*(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
|
||||
return 1;
|
||||
case AF_INET6:
|
||||
*(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
|
||||
{
|
||||
struct sockaddr_storage ss;
|
||||
unsigned long s = size;
|
||||
|
||||
ZeroMemory(&ss, sizeof(ss));
|
||||
ss.ss_family = af;
|
||||
|
||||
switch(af) {
|
||||
case AF_INET:
|
||||
((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
|
||||
break;
|
||||
case AF_INET6:
|
||||
((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
/* cannot direclty use &size because of strict aliasing rules */
|
||||
return (WSAAddressToStringA((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)?
|
||||
dst : NULL;
|
||||
}
|
||||
#endif // defined(_WIN32) && _WIN32_WINNT <= _WIN32_WINNT_WINXP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
nonstd::optional<IpAddress> IpAddress::resolve(std::string address)
|
||||
|
|
Loading…
Reference in New Issue