diff --git a/src/threads/CMakeLists.txt b/src/threads/CMakeLists.txt
index 2ab4e1b..a47620b 100644
--- a/src/threads/CMakeLists.txt
+++ b/src/threads/CMakeLists.txt
@@ -59,6 +59,7 @@ include_directories(
 if (libssh_threads_SRCS)
     set(LIBSSH_THREADS ON CACHE "libssh threads lib" INTERNAL)
 
+    if (NOT WITH_STATIC_LIB)
     add_library(${LIBSSH_THREADS_SHARED_LIBRARY} SHARED ${libssh_threads_SRCS})
 
     target_link_libraries(${LIBSSH_THREADS_SHARED_LIBRARY} ${LIBSSH_THREADS_LINK_LIBRARIES})
@@ -89,7 +90,7 @@ if (libssh_threads_SRCS)
       COMPONENT libraries
     )
 
-    if (WITH_STATIC_LIB)
+    else (WITH_STATIC_LIB)
       add_library(${LIBSSH_THREADS_STATIC_LIBRARY} STATIC ${libssh_threads_SRCS})
 
       if (MSVC)
