From 1cadb38b20dab5713baed762aeb4cda995b72d5e Mon Sep 17 00:00:00 2001
From: Manuel Grizonnet <manuel.grizonnet@orfeo-toolbox.org>
Date: Mon, 23 Feb 2015 11:34:21 +0100
Subject: [PATCH] COMP: prevent any OTB_USE_XXX option to be OFF to compile
 examples

---
 Examples/CMakeLists.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt
index 8c60b06add..beaf8c4196 100644
--- a/Examples/CMakeLists.txt
+++ b/Examples/CMakeLists.txt
@@ -1,7 +1,15 @@
 if(NOT OTB_BUILD_DEFAULT_MODULES)
   message(FATAL_ERROR "BUILD_EXAMPLES requires OTB_BUILD_DEFAULT_MODULES to be ON")
 endif()
-# TODO : we also need to prevent any OTB_USE_XXX option to be OFF
+
+# We also need to prevent any OTB_USE_XXX option to be OFF
+# For now we parse module activation list and test if option is ON. If not the cmake configuration stop.
+#TODO We should provide a better mechanism here wich will deactivate only examples required by deactivated options.
+foreach (_activationOption ${OTB_MODULE_ACTIVATION_OPTION_LIST})
+  if(NOT ${_activationOption})
+    message(FATAL_ERROR "BUILD_EXAMPLES requires ${_activationOption} to be ON")
+  endif()
+endforeach()
 
 find_package(OTB REQUIRED)
 include(${OTB_USE_FILE})
-- 
GitLab