Updated CMake build script for Windows. Moving away from MinGW requirement for build

This commit is contained in:
Joseph Henry
2017-12-19 16:23:52 -08:00
parent 3fe2ed6893
commit 402083a5d8
16 changed files with 163 additions and 133 deletions

View File

@@ -43,11 +43,11 @@
#if defined(__linux__) || defined(__APPLE__)
#include <sys/socket.h>
#include <pthread.h>
#endif
#include "SysUtils.h"
#include <stdint.h>
#include <pthread.h>
#ifdef __linux__
#include <sys/syscall.h>

View File

@@ -32,7 +32,7 @@
#include "Utilities.h"
#if defined(__MINGW32__) || defined(__MINGW64__)
#if defined(_WIN32_FALSE)
#include <WinSock2.h>
#include <stdint.h>

View File

@@ -54,8 +54,9 @@ std::string netDir; // Where network .conf files are to be written
ZeroTier::Mutex _multiplexer_lock;
#if defined(__MINGW32__) || defined(__MINGW64__)
#if defined(_WIN32)
WSADATA wsaData;
#include <Windows.h>
#endif
// prototype
@@ -180,7 +181,11 @@ uint64_t zts_get_node_id_from_file(const char *filepath)
}
// Starts a ZeroTier service in the background
#if defined(_WIN32)
DWORD WINAPI zts_start_service(LPVOID thread_id)
#else
void *zts_start_service(void *thread_id)
#endif
{
DEBUG_INFO("zto-thread, path=%s", homeDir.c_str());
// Where network .conf files will be stored
@@ -414,11 +419,15 @@ int zts_start(const char *path, bool blocking = false)
if (path) {
homeDir = path;
}
#if defined(__MINGW32__) || defined(__MINGW64__)
int err;
#if defined(_WIN32)
WSAStartup(MAKEWORD(2, 2), &wsaData); // initialize WinSock. Used in Phy for loopback pipe
HANDLE thr = CreateThread(NULL, 0, zts_start_service, NULL, 0, NULL);
#else
pthread_t service_thread;
err = pthread_create(&service_thread, NULL, zts_start_service, NULL);
#endif
pthread_t service_thread;
int err = pthread_create(&service_thread, NULL, zts_start_service, NULL);
if (blocking) { // block to prevent service calls before we're ready
ZT_NodeStatus status;
while (zts_core_running() == false || zt1Service->getNode() == NULL) {
@@ -463,7 +472,7 @@ void zts_stop()
zt1Service->terminate();
// disableTaps();
}
#if defined(__MINGW32__) || defined(__MINGW64__)
#if defined(_WIN32)
WSACleanup();
#endif
}
@@ -555,9 +564,13 @@ bool _ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr)
void api_sleep(int interval_ms)
{
#if defined(_WIN32)
Sleep(interval_ms);
#else
struct timespec sleepValue = {0};
sleepValue.tv_nsec = interval_ms * 500000;
nanosleep(&sleepValue, NULL);
#endif
}
#ifdef __cplusplus

View File

@@ -673,7 +673,7 @@ int platform_adjusted_socket_family(int family)
#if defined(__APPLE__)
return family == 30 ? AF_INET6 : family; // 10
#endif
#if defined(__MINGW32__) || defined(__MINGW64__)
#if defined(_WIN32)
return family == 23 ? AF_INET6 : family; // 10
#endif
}

View File

@@ -134,7 +134,7 @@ void lwip_driver_init()
if (lwip_driver_initialized == true) {
return;
}
#if defined(__MINGW32__)
#if defined(_WIN32)
sys_init(); // required for win32 initializtion of critical sections
#endif
sys_thread_new("main_thread", main_thread,