diff --git a/CMakeLists.txt b/CMakeLists.txt
index b53745b..d8787d8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,7 @@
 ENDIF()
 
 IF(WIN32)
-  ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN -MD)
+  ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN)
 ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
   ADD_DEFINITIONS(-DOSX)
 ENDIF()
@@ -73,33 +73,6 @@
     ADD_SUBDIRECTORY(doc)
 ENDIF()
 
-IF (PAHO_ENABLE_CPACK)
-    ### packaging settings
-    FILE(GLOB samples "src/samples/*.c")
-    INSTALL(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR}/samples)
-
-    SET(CPACK_PACKAGE_VENDOR "Eclipse Paho")
-    SET(CPACK_PACKAGE_NAME "Eclipse-Paho-MQTT-C")
-    INSTALL(FILES CONTRIBUTING.md epl-v20 edl-v10 README.md notice.html DESTINATION ${CMAKE_INSTALL_DOCDIR})
-
-    IF (WIN32)
-        SET(CPACK_GENERATOR "ZIP")
-    ELSEIF(PAHO_BUILD_DEB_PACKAGE)
-        INSTALL(FILES CONTRIBUTING.md epl-v20 edl-v10 README.md notice.html DESTINATION ${CMAKE_INSTALL_DOCDIR})
-
-        SET(CPACK_GENERATOR "DEB")
-        CONFIGURE_FILE(${CMAKE_SCRIPTS}/CPackDebConfig.cmake.in
-                ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake @ONLY)
-        SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake)
-        ADD_SUBDIRECTORY(debian)
-    ELSE()
-            SET(CPACK_GENERATOR "TGZ")
-    ENDIF()
-ELSE()
-       FILE(GLOB samples "src/samples/*.c")
-       INSTALL(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR})
-ENDIF()
-
 SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR})
 SET(CPACK_PACKAGE_VERSION_MINOR ${PAHO_VERSION_MINOR})
 SET(CPACK_PACKAGE_VERSION_PATCH ${PAHO_VERSION_PATCH})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b46eaca..399b37d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -57,7 +57,7 @@
 ENDIF()
 
 IF (WIN32)
-    SET(LIBS_SYSTEM ws2_32 crypt32 RpcRT4)
+    SET(LIBS_SYSTEM ws2_32 crypt32 RpcRT4 wsock32)
 ELSEIF (UNIX)
     IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
         SET(LIBS_SYSTEM c dl pthread rt)
diff --git a/src/Thread.c b/src/Thread.c
index 4cb2f16..40ce8dc 100644
--- a/src/Thread.c
+++ b/src/Thread.c
@@ -419,9 +419,16 @@
 	struct timespec cond_timeout;
 
 	FUNC_ENTRY;
+#if defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+    struct timeval cur_time;
+    gettimeofday(&cur_time, NULL);
+    cond_timeout.tv_sec = cur_time.tv_sec + timeout;
+    cond_timeout.tv_nsec = cur_time.tv_usec * 1000;
+#else
 	clock_gettime(CLOCK_REALTIME, &cond_timeout);
 
 	cond_timeout.tv_sec += timeout;
+#endif
 	pthread_mutex_lock(&condvar->mutex);
 	rc = pthread_cond_timedwait(&condvar->cond, &condvar->mutex, &cond_timeout);
 	pthread_mutex_unlock(&condvar->mutex);
diff --git a/src/WebSocket.c b/src/WebSocket.c
index 47b1dad..3f96dac 100644
--- a/src/WebSocket.c
+++ b/src/WebSocket.c
@@ -37,6 +37,11 @@
 #include "SocketBuffer.h"
 #include "StackTrace.h"
 
+#ifdef __MINGW32__
+#define htonll __builtin_bswap64
+#define ntohll __builtin_bswap64
+#endif
+
 #if defined(__linux__)
 #  include <endian.h>
 #elif defined(__APPLE__)

