Fixed DLL compilation on Windows for CMake.
- Define LWS_DLL and LWS_INTERNAL when websockets_shared is compiled.
- The websocket_shared target compiles to websocket.lib / websocket.dll
(websocket.lib contains the exported functions for websocket.dll, and is
the file that is linked to when a program wants to use the dll)
- The websocket target compiles to websocket_static.lib on windows.
- Replaced any "extern" with "LWS_EXTERN" on libwebsockets.h for proper
DLL function exports.
- Created a LIB_LIST with all the libwebsocket dependencies, instead of
multiple calls to target_link_libraries, only one call is made for both
the static and shared library version. This makes it easy to add other
variants if wanted in the future.
- Added ZLIB as a dependency for the libs, so that the build order will be
correct at all times.
- Added a dependency for the websockets lib to the test apps, so it is
built before them.
- Fixed the test-server-extpoll app to include the emulated_poll, and link
to winsock on Windows.
- Removed the global export of libwebsocket_internal_extensions, and added
a function libwebsocket_get_internal_extensions() that returns it
instead. Using the global would not work with the DLL export on Windows.
diff --git a/test-server/test-client.c b/test-server/test-client.c
index 4e8097b..872d2d3 100644
--- a/test-server/test-client.c
+++ b/test-server/test-client.c
@@ -273,7 +273,7 @@
info.port = CONTEXT_PORT_NO_LISTEN;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_internal_extensions;
+ info.extensions = libwebsocket_get_internal_extensions();
#endif
info.gid = -1;
info.uid = -1;
diff --git a/test-server/test-fraggle.c b/test-server/test-fraggle.c
index 5137711..61f868a 100644
--- a/test-server/test-fraggle.c
+++ b/test-server/test-fraggle.c
@@ -301,7 +301,7 @@
info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_internal_extensions;
+ info.extensions = libwebsocket_get_internal_extensions();
#endif
if (use_ssl) {
info.ssl_cert_filepath = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem";
diff --git a/test-server/test-ping.c b/test-server/test-ping.c
index b195280..54b2f67 100644
--- a/test-server/test-ping.c
+++ b/test-server/test-ping.c
@@ -418,7 +418,7 @@
info.port = CONTEXT_PORT_NO_LISTEN;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_internal_extensions;
+ info.extensions = libwebsocket_get_internal_extensions();
#endif
info.gid = -1;
info.uid = -1;
diff --git a/test-server/test-server.c b/test-server/test-server.c
index 1ccffc4..ecf1dd1 100644
--- a/test-server/test-server.c
+++ b/test-server/test-server.c
@@ -29,9 +29,23 @@
#include <string.h>
#include <sys/time.h>
#include <assert.h>
-#ifndef WIN32
+#ifdef WIN32
+
+#ifdef EXTERNAL_POLL
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+ #endif
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+ #include <stddef.h>
+
+ #include "websock-w32.h"
+#endif
+
+#else // NOT WIN32
#include <syslog.h>
#endif
+
#include <signal.h>
#include "../lib/libwebsockets.h"
@@ -600,7 +614,7 @@
info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_internal_extensions;
+ info.extensions = libwebsocket_get_internal_extensions();
#endif
if (!use_ssl) {
info.ssl_cert_filepath = NULL;