diff --git a/CMakeLists.txt b/CMakeLists.txt
index de93c04f73428e76c9c5770f2972465415b8bf21..b8fc2b35927fd69c8ab2b68a67fe19fc8dc48fb5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -322,7 +322,12 @@ if (OPENDHT_C)
         c/opendht_c.h
     )
     target_compile_definitions(opendht-c PRIVATE OPENDHT_C_BUILD)
-    target_link_libraries(opendht-c opendht)
+    if (OPENDHT_SHARED)
+        target_link_libraries(opendht-c opendht)
+    else ()
+        target_link_libraries(opendht-c opendht-static)
+    endif ()
+
     # PkgConfig module
     configure_file (
         opendht-c.pc.in