From 28fed47fa4746581b1bd22f940e2911e554ef356 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Thu, 31 Aug 2017 17:21:58 +0200
Subject: [PATCH] COMP: allow GeoTIFF and TIFF to be disabled when no 3rd party
 drags them

---
 CMake/OTBModuleEnablement.cmake             | 20 ++++++++++++--------
 Modules/ThirdParty/GeoTIFF/otb-module.cmake |  2 ++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/CMake/OTBModuleEnablement.cmake b/CMake/OTBModuleEnablement.cmake
index 749a3b375f..4ec34d94df 100644
--- a/CMake/OTBModuleEnablement.cmake
+++ b/CMake/OTBModuleEnablement.cmake
@@ -157,14 +157,18 @@ macro(otb_module_enable otb-module _needed_by)
   endif()
   if(NOT ${otb-module}_ENABLED)
     set(${otb-module}_ENABLED 1)
-    foreach(dep IN LISTS OTB_MODULE_${otb-module}_DEPENDS)
-      otb_module_enable(${dep} ${otb-module})
-    endforeach()
-    foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS)
-      otb_module_enable(${dep} ${otb-module})
-    endforeach()
-    if(${otb-module}_TESTED_BY AND (OTB_BUILD_DEFAULT_MODULES OR OTB_BUILD_ALL_MODULES_FOR_TESTS OR Module_${otb-module}))
-      otb_module_enable(${${otb-module}_TESTED_BY} "")
+    # if this module has an ACTIVATION_OPTION=OFF, don't bother enable its dependencies
+    if(NOT (OTB_MODULE_${otb-module}_ACTIVATION_OPTION
+     AND NOT ${OTB_MODULE_${otb-module}_ACTIVATION_OPTION}))
+      foreach(dep IN LISTS OTB_MODULE_${otb-module}_DEPENDS)
+        otb_module_enable(${dep} ${otb-module})
+      endforeach()
+      foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS)
+        otb_module_enable(${dep} ${otb-module})
+      endforeach()
+      if(${otb-module}_TESTED_BY AND (OTB_BUILD_DEFAULT_MODULES OR OTB_BUILD_ALL_MODULES_FOR_TESTS OR Module_${otb-module}))
+        otb_module_enable(${${otb-module}_TESTED_BY} "")
+      endif()
     endif()
   endif()
 endmacro()
diff --git a/Modules/ThirdParty/GeoTIFF/otb-module.cmake b/Modules/ThirdParty/GeoTIFF/otb-module.cmake
index 0f331ec157..8fbc7b5248 100644
--- a/Modules/ThirdParty/GeoTIFF/otb-module.cmake
+++ b/Modules/ThirdParty/GeoTIFF/otb-module.cmake
@@ -27,4 +27,6 @@ otb_module(OTBGeoTIFF
     
   DESCRIPTION
     "${DOCUMENTATION}"
+
+  EXCLUDE_FROM_DEFAULT
   )
-- 
GitLab