From 0e0ccbac1ffbf2fdb2d999c5789113aabf3bd0c2 Mon Sep 17 00:00:00 2001
From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org>
Date: Wed, 16 Dec 2009 17:30:40 +0800
Subject: [PATCH] COMP: cleaning compilation process

---
 CMakeLists.txt                             | 36 +++++++++++++++-------
 Examples/DataRepresentation/CMakeLists.txt | 10 +++---
 otbIncludeDirectories.cmake                | 14 +++------
 3 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 89e2e4ffa4..470e9e9443 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -954,14 +954,28 @@ ENDIF(OTB_USE_VISU_GUI)
 OPTION(BUILD_EXAMPLES "Build the Examples directory." OFF)
 
 
+#-----------------------------------------------------------------------------
+# The entire OTB tree should use the same include path
+
+# Create the list of include directories needed for OTB header files.
+INCLUDE(${OTB_SOURCE_DIR}/otbIncludeDirectories.cmake)
+
+# This should be the only INCLUDE_DIRECTORIES command in the entire
+# tree, except for the Utilities and Wrapping directories.  We need to
+# do this in one place to make sure the order is correct.
+INCLUDE_DIRECTORIES(
+  ${OTB_INCLUDE_DIRS_BUILD_TREE}
+  ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
+  ${OTB_INCLUDE_DIRS_SYSTEM}
+)
+
 #-----------------------------------------------------------------------------
 # Dispatch the build into the proper subdirectories.
 
-#Note: SUBDIRS is deprecated and should be replaced by ADD_SUBDIRECTORY
-SUBDIRS(Utilities Code)
-#ADD_SUBDIRECTORY(Utilities)
-#ADD_SUBDIRECTORY(Code)
-#ADD_SUBDIRECTORY(Utilities/otbsvm)
+#Note: SUBDIRS is deprecated and is replaced by ADD_SUBDIRECTORY
+#SUBDIRS(Utilities Code)
+ADD_SUBDIRECTORY(Utilities)
+ADD_SUBDIRECTORY(Code)
 
 IF (BUILD_EXAMPLES)
   ADD_SUBDIRECTORY(Examples)
@@ -1031,16 +1045,16 @@ CONFIGURE_FILE(${OTB_SOURCE_DIR}/otbConfigure.h.in
 # The entire OTB tree should use the same include path
 
 # Create the list of include directories needed for OTB header files.
-INCLUDE(${OTB_SOURCE_DIR}/otbIncludeDirectories.cmake)
+#INCLUDE(${OTB_SOURCE_DIR}/otbIncludeDirectories.cmake)
 
 # This should be the only INCLUDE_DIRECTORIES command in the entire
 # tree, except for the Utilities and Wrapping directories.  We need to
 # do this in one place to make sure the order is correct.
-INCLUDE_DIRECTORIES(
-  ${OTB_INCLUDE_DIRS_BUILD_TREE}
-  ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
-  ${OTB_INCLUDE_DIRS_SYSTEM}
-)
+#INCLUDE_DIRECTORIES(
+#  ${OTB_INCLUDE_DIRS_BUILD_TREE}
+#  ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
+#  ${OTB_INCLUDE_DIRS_SYSTEM}
+#)
 
 #-----------------------------------------------------------------------------
 # Uninstall cmake use to uninstall OTB.
diff --git a/Examples/DataRepresentation/CMakeLists.txt b/Examples/DataRepresentation/CMakeLists.txt
index af9cf4a881..0244adc488 100644
--- a/Examples/DataRepresentation/CMakeLists.txt
+++ b/Examples/DataRepresentation/CMakeLists.txt
@@ -1,6 +1,4 @@
-SUBDIRS( 
-  Containers
-  Image
-  Mesh
-  Path
-  )
+ADD_SUBDIRECTORY(Containers)
+ADD_SUBDIRECTORY(Image)
+ADD_SUBDIRECTORY(Mesh)
+ADD_SUBDIRECTORY(Path)
diff --git a/otbIncludeDirectories.cmake b/otbIncludeDirectories.cmake
index 86c5e08598..98fe0a733a 100644
--- a/otbIncludeDirectories.cmake
+++ b/otbIncludeDirectories.cmake
@@ -19,7 +19,10 @@ ELSE(OTB_USE_EXTERNAL_BOOST)
 )
 ENDIF(OTB_USE_EXTERNAL_BOOST)
 
-
+#-----------------------------------------------------------------------------
+# Include directories from the GDAL build tree.
+SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
+    ${GDAL_INCLUDE_DIR} )
 
 # These directories are always needed.
 SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
@@ -97,10 +100,7 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
 )
 
 
-#-----------------------------------------------------------------------------
-# Include directories from the GDAL build tree.
-SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
-  	${GDAL_INCLUDE_DIR} )
+
 #-----------------------------------------------------------------------------
 # Include directories from the CURL build tree.
 IF(OTB_USE_CURL)
@@ -221,10 +221,6 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE_CXX ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX} )
 SET(OTB_INCLUDE_DIRS_BUILD_TREE_CXX ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
   		${OTB_GLU_INCLUDE_PATH} )
 
-#For GDAL header file
-SET(OTB_INCLUDE_DIRS_BUILD_TREE_CXX ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
-  		${GDAL_INCLUDE_DIR} )
-
 #For EXPAT header file
 IF(OTB_USE_EXTERNAL_EXPAT)
         SET(OTB_INCLUDE_DIRS_BUILD_TREE_CXX ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
-- 
GitLab