---- CMakeLists.txt.orig	2019-02-15 22:43:24.189777825 +0100
-+++ CMakeLists.txt	2019-02-15 22:49:23.543102100 +0100
+--- CMakeLists.txt.orig	2019-02-16 23:43:52.372836136 +0100
++++ CMakeLists.txt	2019-02-17 00:02:53.036141198 +0100
 @@ -1,4 +1,4 @@
 -cmake_minimum_required(VERSION 2.8.9)
-+cmake_minimum_required(VERSION 2.6.4)
++cmake_minimum_required(VERSION 2.6.2)
  
  # General Advice
  #
-@@ -1055,9 +1055,9 @@
+@@ -326,8 +326,10 @@
+ endif()
+ 
+ 
+-if (LWS_WITH_HTTP_PROXY AND (LWS_WITHOUT_CLIENT OR LWS_WITHOUT_SERVER))
+-	message(FATAL_ERROR "You have to enable both client and server for http proxy")
++if (LWS_WITH_HTTP_PROXY)
++  if (LWS_WITHOUT_CLIENT OR LWS_WITHOUT_SERVER)
++	  message(FATAL_ERROR "You have to enable both client and server for http proxy")
++	endif()
+ endif()
+ 
+ # Allow the user to override installation directories.
+@@ -351,7 +353,7 @@
+ 	message(FATAL_ERROR "Makes no sense to compile with neither client nor server.")
+ endif()
+ 
+-if (NOT (LWS_WITH_STATIC OR LWS_WITH_SHARED))
++if (NOT LWS_WITH_STATIC AND NOT LWS_WITH_SHARED)
+ 	message(FATAL_ERROR "Makes no sense to compile with neither static nor shared libraries.")
+ endif()
+ 
+@@ -590,7 +592,7 @@
+ endif()
+ 
+ # Put the libraries and binaries that get built into directories at the
+-# top of the build tree rather than in hard-to-find leaf directories. 
++# top of the build tree rather than in hard-to-find leaf directories.
+ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
+ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
+ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
+@@ -663,7 +665,7 @@
+ CHECK_INCLUDE_FILE(malloc.h LWS_HAVE_MALLOC_H)
+ CHECK_INCLUDE_FILE(pthread.h LWS_HAVE_PTHREAD_H)
+ 
+-CHECK_LIBRARY_EXISTS(cap cap_set_flag "" LWS_HAVE_LIBCAP) 
++CHECK_LIBRARY_EXISTS(cap cap_set_flag "" LWS_HAVE_LIBCAP)
+ 
+ if (LWS_WITH_LIBUV)
+ CHECK_INCLUDE_FILE(uv-version.h LWS_HAVE_UV_VERSION_H)
+@@ -685,7 +687,7 @@
+ 
+ CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
+ 
+-CHECK_C_SOURCE_COMPILES("#include <stdint.h> 
++CHECK_C_SOURCE_COMPILES("#include <stdint.h>
+ 	int main(void) {
+ 		intptr_t test = 1;
+ 		return 0;
+@@ -801,7 +803,7 @@
+ 
+ if (LWS_WITH_MBEDTLS)
+  	set(LWS_WITH_SSL ON)
+- 	
++
+ 	list(APPEND HDR_PRIVATE
+ 		lib/tls/mbedtls/wrapper/include/internal/ssl3.h
+ 		lib/tls/mbedtls/wrapper/include/internal/ssl_cert.h
+@@ -845,7 +847,7 @@
+ 	list(APPEND SOURCES
+ 		lib/tls/tls.c
+ 	)
+-		
++
+ 		if (LWS_WITH_MBEDTLS)
+ 			list(APPEND SOURCES
+ 				lib/tls/mbedtls/ssl.c
+@@ -875,7 +877,7 @@
+ 				)
+ 			endif()
+ 		endif()
+-		
++
+ 	if (NOT LWS_WITHOUT_SERVER)
+ 		list(APPEND SOURCES
+ 			lib/tls/tls-server.c)
+@@ -897,7 +899,7 @@
+ 			list(APPEND SOURCES
+ 				lib/tls/openssl/openssl-client.c)
+ 		endif()
+-		
++
+ 	endif()
+ endif()
+ 
+@@ -934,10 +936,12 @@
+ 	endif()
+ endif()
+ 
+-if ((LWS_ROLE_H1 OR LWS_ROLE_H2) AND NOT LWS_WITHOUT_SERVER)
+-	list(APPEND SOURCES
+-		lib/roles/http/server/server.c
+-		lib/roles/http/server/lws-spa.c)
++if (LWS_ROLE_H1 OR LWS_ROLE_H2)
++  if (NOT LWS_WITHOUT_SERVER)
++	  list(APPEND SOURCES
++		  lib/roles/http/server/server.c
++		  lib/roles/http/server/lws-spa.c)
++  endif()
+ endif()
+ 
+ if (LWS_ROLE_WS AND NOT LWS_WITHOUT_EXTENSIONS)
+@@ -976,7 +980,7 @@
+ if (LWS_WITH_LEJP)
+ 	list(APPEND SOURCES
+ 		lib/misc/lejp.c)
+-endif()	
++endif()
+ if (LWS_WITH_LEJP_CONF)
+ 		list(APPEND SOURCES
+ 			"lib/roles/http/server/lejp-conf.c"
+@@ -1038,7 +1042,7 @@
+ 	endif()
+ endif()
+ 
+-if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
++if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+     include (CheckCCompilerFlag)
+     CHECK_C_COMPILER_FLAG(-fvisibility=hidden LWS_HAVE_VISIBILITY)
+     if (LWS_HAVE_VISIBILITY)
+@@ -1055,21 +1059,23 @@
      endif()
  
      if (UNIX AND NOT LWS_WITH_ESP32)

+#export(PACKAGE libwebsockets)
 
 # Generate the config file for the build-tree.
 set(LWS__INCLUDE_DIRS 

     endif()
 endif ()
 
-if ((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT LWS_WITHOUT_TESTAPPS)
-	if (UNIX AND LWS_HAVE_PTHREAD_H)
-	# jeez clang understands -pthread but dies if he sees it at link time!
-	# http://stackoverflow.com/questions/2391194/what-is-gs-pthread-equiv-in-clang
-	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread" )
+if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+  if (NOT LWS_WITHOUT_TESTAPPS)
+	  if (UNIX AND LWS_HAVE_PTHREAD_H)
+	    # jeez clang understands -pthread but dies if he sees it at link time!
+	    # http://stackoverflow.com/questions/2391194/what-is-gs-pthread-equiv-in-clang
+	    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread" )
     endif()
+  endif()
 endif()
 
-if ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
+if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
 	# otherwise osx blows a bunch of openssl deprecated api errors
 	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations" )
 endif()
@@ -1157,7 +1163,7 @@
 
 # Set the so version of the lib.
 # Equivalent to LDFLAGS=-version-info x:x:x
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
 	foreach(lib ${LWS_LIBRARIES})
 		set_target_properties(${lib}
 			PROPERTIES
@@ -1520,7 +1526,7 @@
 		endif()
 	endif()
 
-	list(APPEND TEST_SERVER_DATA 
+	list(APPEND TEST_SERVER_DATA
 		"${TEST_SERVER_SSL_KEY}"
 		"${TEST_SERVER_SSL_CERT}")
 endif()
@@ -1532,7 +1538,8 @@
 # Test applications
 #
 set(TEST_APP_LIST)
-if ((LWS_ROLE_H1 OR LWS_ROLE_H2) AND NOT LWS_WITHOUT_TESTAPPS)
+if (LWS_ROLE_H1 OR LWS_ROLE_H2)
+if (NOT LWS_WITHOUT_TESTAPPS)
 	#
 	# Helper function for adding a test app.
 	#
@@ -1608,7 +1615,7 @@
 
 	if (UNIX AND LWS_WITH_PLUGINS)
 		set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
-		if(NOT((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR (${CMAKE_SYSTEM_NAME} MATCHES "QNX")))
+		if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
 			target_link_libraries(websockets dl)
 		endif()
 	endif()
@@ -1666,8 +1673,8 @@
 			# Set defines for this executable only.
 			set_property(
 				TARGET test-server-extpoll
-				PROPERTY COMPILE_DEFINITIONS 
-					EXTERNAL_POLL 
+				PROPERTY COMPILE_DEFINITIONS
+					EXTERNAL_POLL
 					INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share"
 				)
 
@@ -1700,7 +1707,7 @@
 			"${PROJECT_SOURCE_DIR}/test-apps/test.html")
 
 		add_custom_command(TARGET test-server
-						POST_BUILD 
+						POST_BUILD
 						COMMAND "${CMAKE_COMMAND}" -E make_directory "$<TARGET_FILE_DIR:test-server>/../share/libwebsockets-test-server")
 
 		# Copy the file needed to run the server so that the test apps can
@@ -1708,7 +1715,7 @@
 		foreach (TEST_FILE ${TEST_SERVER_DATA})
 			if (EXISTS ${TEST_FILE})
 				add_custom_command(TARGET test-server
-							POST_BUILD 
+							POST_BUILD
 							COMMAND "${CMAKE_COMMAND}" -E copy "${TEST_FILE}" "$<TARGET_FILE_DIR:test-server>/../share/libwebsockets-test-server" VERBATIM)
 			endif()
 		endforeach()
@@ -1723,8 +1730,8 @@
 		endif()
 
 	endif(NOT LWS_WITHOUT_CLIENT)
-	
-	
+
+
 	if (LWS_WITH_PLUGINS AND LWS_WITH_SHARED)
 		macro(create_plugin PLUGIN_NAME PLUGIN_INCLUDE MAIN_SRC S2 S3)
 
@@ -1755,7 +1762,7 @@
 		source_group("Headers Private"   FILES ${PLUGIN_HDR})
 		source_group("Sources"   FILES ${PLUGIN_SRCS})
 		add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR})
-		
+
 		target_link_libraries(${PLUGIN_NAME} websockets_shared)
 		add_dependencies(${PLUGIN_NAME} websockets_shared)
 		include_directories(${PLUGIN_INCLUDE})
@@ -1773,7 +1780,7 @@
 		list(APPEND PLUGINS_LIST ${PLUGIN_NAME})
 
 		endmacro()
-		
+
 if (LWS_ROLE_WS)
 		create_plugin(protocol_dumb_increment ""
 			      "plugins/protocol_dumb_increment.c" "" "")
@@ -1873,7 +1880,8 @@
 			endforeach()
 		endif()
 	endif()
-endif((LWS_ROLE_H1 OR LWS_ROLE_H2) AND NOT LWS_WITHOUT_TESTAPPS)
+endif(NOT LWS_WITHOUT_TESTAPPS)
+endif(LWS_ROLE_H1 OR LWS_ROLE_H2)
 
 if (LWS_WITH_LWSWS)
 		list(APPEND LWSWS_SRCS
@@ -1967,38 +1975,39 @@
             FILE "${PROJECT_BINARY_DIR}/LibwebsocketsTargets.cmake")
 endif()
 
