diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2eaf4cc..1cdac22 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -214,6 +214,11 @@ if(WIN32)
   list(APPEND SOURCES ${PROJECT_SOURCE_DIR}/win32/libssh2.rc)
 endif()
 
+if(UNIX AND NOT APPLE)
+  find_package(Threads REQUIRED)
+  list(APPEND LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+endif()
+
 add_library(libssh2 ${SOURCES})
 # we want it to be called libssh2 on all platforms
 set_target_properties(libssh2 PROPERTIES PREFIX "")
