diff --git a/CMakeLists.txt b/CMakeLists.txt
index b9d6f19c4223f5b209b4312998f9a97a6b824c79..b055fdad462a1039d53203fd86e52de81d5f6ebd 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.1)
 project (dap_udp_server C)
 
 if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
-    add_subdirectory(libdap-server-core)
+    if ( NOT ( TARGET dap_core_server ) )
+        add_subdirectory(libdap-server-core)
+    endif()
     enable_testing()
     add_subdirectory(test)
 endif()
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index ef2ee706391edcc0ebdb7818324fb8e8de302679..998462efc70d1e565c198cca14e9d87496a3fc84 100755
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -3,7 +3,9 @@ project(udp-server-test)
 
 set(CMAKE_C_STANDARD 11)
 
-add_subdirectory(libdap-test)
+if ( NOT ( TARGET dap_test ) )
+    add_subdirectory(libdap-test)
+endif()
 
 file(GLOB SRC *.h *.c)