From 2cb705f71fe176ac2746d15d7dfda21a0eaaa830 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 6 Feb 2020 06:51:19 +0000 Subject: [PATCH] cmake: make sure libz is at end of link if enabled https://github.com/warmcat/libwebsockets/issues/1840 --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5218b6f90..e9ad1d2d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1764,7 +1764,8 @@ if (LWS_WITH_ZLIB) message("zlib/miniz include dirs: ${ZLIB_INCLUDE_DIRS}") message("zlib/miniz libraries: ${ZLIB_LIBRARIES}") include_directories(${ZLIB_INCLUDE_DIRS}) - list(APPEND LIB_LIST ${ZLIB_LIBRARIES}) + # done later at end of link list + # list(APPEND LIB_LIST ${ZLIB_LIBRARIES}) endif() if (LWS_WITH_HTTP_BROTLI) @@ -1933,6 +1934,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") list(APPEND LIB_LIST socket) endif() +# +# add libs here that need to be at the end of the link order +# + if (UNIX) list(APPEND LIB_LIST m) endif() @@ -1953,6 +1958,9 @@ if (UNIX) list(APPEND LIB_LIST dl) endif() +if (LWS_WITH_ZLIB AND NOT LWS_WITH_BUNDLED_ZLIB) + list(APPEND LIB_LIST "${ZLIB_LIBRARIES}") +endif() # Setup the linking for all libs. foreach (lib ${LWS_LIBRARIES})