From 2420e4a981324e5abf1305ce734f6876c5fa161c Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 23 May 2022 14:15:19 +0200 Subject: [PATCH] cmake: Move the ws2_32 as the last library for mingw to work Fixes: https://gitlab.com/libssh/libssh-mirror/-/issues/84 Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- src/CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f350d9d..08ba2aa9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,13 +9,6 @@ set(LIBSSH_LINK_LIBRARIES ${LIBSSH_REQUIRED_LIBRARIES} ) -if (WIN32) - set(LIBSSH_LINK_LIBRARIES - ${LIBSSH_LINK_LIBRARIES} - ws2_32 - ) -endif (WIN32) - if (OPENSSL_CRYPTO_LIBRARIES) set(LIBSSH_PRIVATE_INCLUDE_DIRS ${LIBSSH_PRIVATE_INCLUDE_DIRS} @@ -93,6 +86,15 @@ if (MINGW AND Threads_FOUND) ) endif() +# This needs to be last for mingw to build +# https://gitlab.com/libssh/libssh-mirror/-/issues/84 +if (WIN32) + set(LIBSSH_LINK_LIBRARIES + ${LIBSSH_LINK_LIBRARIES} + ws2_32 + ) +endif (WIN32) + if (BUILD_STATIC_LIB) set(LIBSSH_STATIC_LIBRARY ssh_static