From f7d5cb83826c7e2b1a3dc618b434d85df130a4d5 Mon Sep 17 00:00:00 2001
From: James Taylor <james@jtaylor.id.au>
Date: Tue, 10 Dec 2019 21:58:45 +1100
Subject: [PATCH] Explicitly link against WSLAY when available

When other libraries attempt to link against libh2o and libh2o-evloop that was
compiled with libwslay available, there are errors from missing symbols
associated with code which makes use of the wslay library. To rectify this,
explicitly link against libwslay during the build process.

Fixes #2105

Signed-off-by: James Taylor <james@jtaylor.id.au>
---
 CMakeLists.txt | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -386,13 +386,21 @@ SET_TARGET_PROPERTIES(libh2o PROPERTIES
     OUTPUT_NAME h2o
     VERSION ${LIBRARY_VERSION}
     SOVERSION ${LIBRARY_SOVERSION})
-TARGET_LINK_LIBRARIES(libh2o ${LIBUV_LIBRARIES} ${EXTRA_LIBS})
+IF (WSLAY_FOUND)
+    TARGET_LINK_LIBRARIES(libh2o ${WSLAY_LIBRARIES} ${LIBUV_LIBRARIES} ${EXTRA_LIBS})
+ELSE ()
+    TARGET_LINK_LIBRARIES(libh2o ${LIBUV_LIBRARIES} ${EXTRA_LIBS})
+ENDIF (WSLAY_FOUND)
 SET_TARGET_PROPERTIES(libh2o-evloop PROPERTIES
     OUTPUT_NAME h2o-evloop
     COMPILE_FLAGS "-DH2O_USE_LIBUV=0"
     VERSION ${LIBRARY_VERSION}
     SOVERSION ${LIBRARY_SOVERSION})
-TARGET_LINK_LIBRARIES(libh2o-evloop ${EXTRA_LIBS})
+IF (WSLAY_FOUND)
+    TARGET_LINK_LIBRARIES(libh2o-evloop ${WSLAY_LIBRARIES} ${EXTRA_LIBS})
+ELSE ()
+    TARGET_LINK_LIBRARIES(libh2o-evloop ${EXTRA_LIBS})
+ENDIF (WSLAY_FOUND)
 
 IF (OPENSSL_FOUND)
     TARGET_INCLUDE_DIRECTORIES(libh2o PUBLIC ${OPENSSL_INCLUDE_DIR})
