diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 83fd054c1a9b6b19c10762bc3ae78a6f68081758..8d6f0e3b9591ae9ac9fc030ae69e27fd12f7bf88 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -58,10 +58,13 @@ FOREACH(lib ${libs})
   INSTALL(TARGETS ${lib} DESTINATION lib/plugin)
   # build python submodule
   STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${lib})
-
+  ADD_DEPENDENCIES(${lib} MKDIR_${PYTHON_LIBRARY_NAME})
+  ADD_CUSTOM_TARGET(MKDIR_${PYTHON_LIBRARY_NAME}
+    mkdir -p dynamic_graph/sot/dynamics/${PYTHON_LIBRARY_NAME}
+    )
   DYNAMIC_GRAPH_PYTHON_MODULE("sot/dynamics/${PYTHON_LIBRARY_NAME}"
     ${lib}
-    sot-dynamics-${PYTHON_LIBRARY_NAME}-wrap
+    sot/dynamics/${PYTHON_LIBRARY_NAME}/wrap
     )
 ENDFOREACH(lib)