diff --git a/CMake/OTBModuleAPI.cmake b/CMake/OTBModuleAPI.cmake
index ba06525b9d18c9aaea7003c19c52f536a077ed45..a6491f86ca10cafda7b8adc5095993db1183d58f 100644
--- a/CMake/OTBModuleAPI.cmake
+++ b/CMake/OTBModuleAPI.cmake
@@ -11,7 +11,7 @@ macro(_otb_module_use_recurse mod)
       _otb_module_use_recurse(${dep})
     endforeach()
     foreach(dep IN LISTS ${mod}_OPTIONAL_DEPENDS)
-      if (${otb-module}_ENABLED)
+      if (${dep}_ENABLED)
         _otb_module_use_recurse(${dep})
       endif()
     endforeach()