diff --git a/code/ryzom/server/src/CMakeLists.txt b/code/ryzom/server/src/CMakeLists.txt
index 73e0536d1..fc91decc4 100644
--- a/code/ryzom/server/src/CMakeLists.txt
+++ b/code/ryzom/server/src/CMakeLists.txt
@@ -1,8 +1,10 @@
 # Supporting modules and libraries.
 # Need servershare for build packed collision tool
 # Need aishare for build wmap tool
-ADD_SUBDIRECTORY(server_share)
-ADD_SUBDIRECTORY(ai_share)
+IF(WITH_RYZOM_TOOLS OR WITH_RYZOM_SERVER)
+  ADD_SUBDIRECTORY(server_share)
+  ADD_SUBDIRECTORY(ai_share)
+ENDIF()
 
 IF(WITH_RYZOM_SERVER)