diff --git a/CMake/CommonDefinitions.cmake b/CMake/CommonDefinitions.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..355878e62066318f7273af9ccad4013bd9ed705e
--- /dev/null
+++ b/CMake/CommonDefinitions.cmake
@@ -0,0 +1,89 @@
+# This file contains the common build definitions and flags used by default when building all targets
+
+IF(WIN32)
+  # do not build shared lib under windows
+  SET(BUILD_SHARED_LIBS OFF)
+  MESSAGE("Disabling build shared lib option on windows like OS.")
+ELSE(WIN32)
+  # on other systems, leave the choice to the user
+  OPTION(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON)
+ENDIF(WIN32)
+
+SET(OTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+
+# OSSIM_STATIC macro
+IF(NOT OTB_BUILD_SHARED_LIBS)
+  ADD_DEFINITIONS(-DOSSIM_STATIC)
+ENDIF(NOT OTB_BUILD_SHARED_LIBS)
+
+# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
+# warnings
+IF(WIN32)
+    IF(NOT CYGWIN)
+      IF(NOT MINGW)
+        IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
+          ADD_DEFINITIONS(
+            -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
+            -D_CRT_IS_WCTYPE_NO_DEPRECATE
+            -D_CRT_MANAGED_FP_NO_DEPRECATE
+            -D_CRT_NONSTDC_NO_DEPRECATE
+            -D_CRT_SECURE_NO_DEPRECATE
+            -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
+            -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
+            -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
+            -D_CRT_VCCLRIT_NO_DEPRECATE
+            -D_SCL_SECURE_NO_DEPRECATE
+            )
+        ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
+        
+        IF (MSVC)
+          ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
+          ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNING)
+        ENDIF(MSVC)
+        
+      ENDIF(NOT MINGW)
+    ENDIF(NOT CYGWIN)
+ENDIF(WIN32)
+
+# __CYGWIN__ must be define for ossim (ex: ossimCommon.h, isnan definition, .. )
+#IF(CYGWIN)
+#  ADD_DEFINITIONS(-D__CYGWIN__)
+#ENDIF(CYGWIN)
+
+
+# Large File Support (> 4Go)
+ADD_DEFINITIONS(
+    -D_LARGEFILE_SOURCE
+    -D_FILE_OFFSET_BITS=64
+    -D_LARGEFILE64_SOURCE
+    -D_LARGE_FILES
+    )
+
+# Pedantic mode
+SET(OTB_BUILD_PEDANTIC OFF CACHE BOOL
+    "Choose compilation in pedantic or relaxed mode")
+
+IF(OTB_BUILD_PEDANTIC)
+    IF(WIN32)
+      IF (MSVC)
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
+      ENDIF(MSVC)
+    ELSE(WIN32)
+      IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
+      ENDIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+    ENDIF(WIN32)
+ENDIF(OTB_BUILD_PEDANTIC)
+
+
+# Full compilation warning mode
+OPTION(OTB_COMPILE_WITH_FULL_WARNING "OTB developers : Compilation with FULL warning (use only for otb developers)." OFF)
+MARK_AS_ADVANCED(OTB_COMPILE_WITH_FULL_WARNING)
+IF(OTB_COMPILE_WITH_FULL_WARNING)
+  IF(CMAKE_COMPILER_IS_GNUCXX)
+    SET(OTB_FULL_WARNING_LIST_PARAMETERS "-Wall -Wunused  -Wunused-function  -Wunused-label  -Wunused-parameter -Wunused-value -Wunused-variable -Wuninitialized -Wsign-compare -Wparentheses -Wunknown-pragmas -Wswitch" CACHE STRING "List of compilation parameters.")
+    MARK_AS_ADVANCED(OTB_FULL_WARNING_LIST_PARAMETERS)
+  ENDIF(CMAKE_COMPILER_IS_GNUCXX)
+ENDIF(OTB_COMPILE_WITH_FULL_WARNING)
+
+
diff --git a/CMake/GenerateConfigProperties.cmake b/CMake/GenerateConfigProperties.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..15eb32f962e83668bf5175d56cccbebe78dae229
--- /dev/null
+++ b/CMake/GenerateConfigProperties.cmake
@@ -0,0 +1,12 @@
+
+FILE(GLOB otbconfigfileCreation_SRCS "${OTB_SOURCE_DIR}/CMake/GenerateConfigProperties.cpp")
+SET(otbconfigfile_DEFAULT "${OTB_BINARY_DIR}/otb.conf")
+
+ADD_EXECUTABLE(GenerateConfigProperties ${otbconfigfileCreation_SRCS})
+
+ADD_CUSTOM_COMMAND(
+          TARGET GenerateConfigProperties
+          POST_BUILD
+          COMMAND GenerateConfigProperties
+          ARGS "${otbconfigfile_DEFAULT}" "${OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING}" "${OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING}"
+          COMMENT "Generating ${otbconfigfile_DEFAULT}" )
diff --git a/CMake/ImportBoost.cmake b/CMake/ImportBoost.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..c96ae9b46bf60f5ef03d69a016f2c8c25741dc53
--- /dev/null
+++ b/CMake/ImportBoost.cmake
@@ -0,0 +1,47 @@
+MESSAGE(STATUS "Importing Boost...")
+SET (Boost_MINOR_VERSION 0)
+
+OPTION(OTB_USE_EXTERNAL_BOOST "Use an outside build of Boost." OFF)
+MARK_AS_ADVANCED(OTB_USE_EXTERNAL_BOOST)
+
+IF(OTB_USE_EXTERNAL_BOOST)
+  # Import the package
+  FIND_PACKAGE(Boost)
+  IF(Boost_FOUND)
+    MESSAGE(STATUS "  Found Boost version ${Boost_VERSION}")
+    IF( ${Boost_MINOR_VERSION} EQUAL 40)
+      MESSAGE(WARNING "Boost 1.40 not supported. Disabling OTB_USE_EXTERNAL_BOOST")
+      SET(OTB_USE_EXTERNAL_BOOST  OFF)
+    ENDIF(${Boost_MINOR_VERSION} EQUAL 40)
+    IF( ${Boost_MINOR_VERSION} LESS 35)
+      MESSAGE(WARNING "Boost >= 1.35 is required. Disabling OTB_USE_EXTERNAL_BOOST")
+      SET(OTB_USE_EXTERNAL_BOOST  OFF)
+    ENDIF(${Boost_MINOR_VERSION} LESS 35)
+  ELSE(Boost_FOUND)
+    MESSAGE(FATAL_ERROR
+                  "Cannot build OTB project without boost library.  Please set Boost directories or set OTB_USE_EXTERNAL_BOOST to OFF to use the INTERNAL Boost version")
+  ENDIF(Boost_FOUND)
+  
+  # Test package completeness
+  TRY_COMPILE(BOOST_IS_COMPLETE
+              ${CMAKE_CURRENT_BINARY_DIR}/CMake
+              ${CMAKE_CURRENT_SOURCE_DIR}/CMake/otbTestCompileBoost.cxx
+              CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${Boost_INCLUDE_DIR}"
+              OUTPUT_VARIABLE OUTPUT)
+
+  IF(BOOST_IS_COMPLETE)
+    MESSAGE(STATUS "  Testing external Boost library    -- yes")
+  ELSE(BOOST_IS_COMPLETE)
+    MESSAGE(STATUS "  Testing external Boost library    -- no")
+    MESSAGE(STATUS "  Forcing the OTB_USE_EXTERNAL_BOOST value to OFF")
+    SET(OTB_USE_EXTERNAL_BOOST OFF CACHE BOOL  "Use an outside build of Boost" FORCE )
+  ENDIF(BOOST_IS_COMPLETE)
+ENDIF(OTB_USE_EXTERNAL_BOOST)
+
+
+IF(OTB_USE_EXTERNAL_BOOST)
+  MESSAGE(STATUS "  Using Boost external version")
+  MESSAGE(STATUS "  Boost includes : ${Boost_INCLUDE_DIR}")
+ELSE(OTB_USE_EXTERNAL_BOOST)
+  MESSAGE(STATUS "  Using Boost internal version")
+ENDIF(OTB_USE_EXTERNAL_BOOST)
diff --git a/CMake/ImportCurl.cmake b/CMake/ImportCurl.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..aed13358d2f3811ddb639d0b72fe21c12873919e
--- /dev/null
+++ b/CMake/ImportCurl.cmake
@@ -0,0 +1,46 @@
+MESSAGE(STATUS "Importing Curl...")
+FIND_PACKAGE(CURL)
+IF(CURL_FOUND)
+  OPTION(OTB_USE_CURL "Use curl library." ON)
+ELSE(CURL_FOUND)
+  OPTION(OTB_USE_CURL "Use curl library." OFF)
+ENDIF(CURL_FOUND)
+
+MARK_AS_ADVANCED(OTB_USE_CURL)
+IF(OTB_USE_CURL)
+
+        FIND_PATH(CURL_INCLUDE_DIR curl/curl.h PATHS)
+        MARK_AS_ADVANCED(CURL_INCLUDE_DIR)
+        IF (NOT CURL_INCLUDE_DIR)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find CURL include directory. Please set CURL_INCLUDE_DIR or SET OTB_USE_CURL OFF.")
+        ENDIF (NOT CURL_INCLUDE_DIR)
+
+        FIND_LIBRARY(CURL_LIBRARY curl )
+        MARK_AS_ADVANCED(CURL_LIBRARY)
+        IF (NOT CURL_LIBRARY)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find CURL library. Please set CURL_LIBRARY or SET OTB_USE_CURL OFF.")
+        ENDIF (NOT CURL_LIBRARY)
+
+        # Add compiler option
+        ADD_DEFINITIONS(-DOTB_USE_CURL)
+
+        INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
+
+        TRY_COMPILE(OTB_CURL_MULTI_AVAILABLE
+                    ${CMAKE_CURRENT_BINARY_DIR}/CMake
+                    ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestCurlMulti.cxx
+                    CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${CURL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${CURL_LIBRARY}"
+                    OUTPUT_VARIABLE OUTPUT)
+        IF (OTB_CURL_MULTI_AVAILABLE)
+          ADD_DEFINITIONS(-DOTB_CURL_MULTI_AVAILABLE)
+        ENDIF (OTB_CURL_MULTI_AVAILABLE)
+         
+        MESSAGE(STATUS "  Enabling Curl support")
+        MESSAGE(STATUS "  Curl includes : ${CURL_INCLUDE_DIR}")
+        MESSAGE(STATUS "  Curl library  : ${CURL_LIBRARY}")
+
+ELSE(OTB_USE_CURL)    
+        MESSAGE(STATUS "  Disabling Curl support")
+ENDIF(OTB_USE_CURL)
diff --git a/CMake/ImportExpat.cmake b/CMake/ImportExpat.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..dca1b79b503553d2e62b54fda49cafb5f8bc5e4a
--- /dev/null
+++ b/CMake/ImportExpat.cmake
@@ -0,0 +1,34 @@
+MESSAGE(STATUS "Importing Expat...")
+FIND_PACKAGE(EXPAT)
+IF(EXPAT_FOUND)
+  OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." ON)
+ELSE(EXPAT_FOUND)
+  OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." OFF)
+ENDIF(EXPAT_FOUND)
+
+MARK_AS_ADVANCED(OTB_USE_EXTERNAL_EXPAT)
+
+IF(OTB_USE_EXTERNAL_EXPAT)
+    FIND_PACKAGE(EXPAT)
+    IF(EXPAT_FOUND)
+        # Control expat compatibility
+        INCLUDE_DIRECTORIES(BEFORE ${EXPAT_INCLUDE_DIR})
+        LINK_DIRECTORIES( ${EXPAT_LIBRARY} )
+    ELSE(EXPAT_FOUND)
+        MESSAGE(FATAL_ERROR
+                  "Cannot build OTB project without lib EXPAT.  Please set EXPAT_DIR or set OTB_USE_EXTERNAL_EXPAT OFF to use INTERNAL EXPAT set on OTB/Utilities repository.")
+    ENDIF(EXPAT_FOUND)
+    
+    MESSAGE(STATUS "  Using Expat external version")
+    MESSAGE(STATUS "  Expat includes : ${EXPAT_INCLUDE_DIR}")
+    MESSAGE(STATUS "  Expat library  : ${EXPAT_LIBRARY}")
+ELSE(OTB_USE_EXTERNAL_EXPAT)
+    ADD_DEFINITIONS(-DOTB_USE_INTERNAL_EXPAT)
+    INCLUDE_DIRECTORIES(BEFORE "${OTB_SOURCE_DIR}/Utilities/otbexpat")
+    INCLUDE_DIRECTORIES(BEFORE "${OTB_BINARY_DIR}/Utilities/otbexpat")
+    IF(NOT BUILD_SHARED_LIBS)
+      ADD_DEFINITIONS(-DXML_STATIC)
+    ENDIF(NOT BUILD_SHARED_LIBS)
+    
+    MESSAGE(STATUS "  Using Expat internal version")
+ENDIF(OTB_USE_EXTERNAL_EXPAT)
diff --git a/CMake/ImportFLTK.cmake b/CMake/ImportFLTK.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..43c70a62ff30802b70f54a93b5a46dab84e77b1a
--- /dev/null
+++ b/CMake/ImportFLTK.cmake
@@ -0,0 +1,74 @@
+MESSAGE(STATUS "Importing FLTK...")
+OPTION(OTB_USE_VISU_GUI "Generate Gui/Visu tools directory. If ON, find OpenGL and FLTK packages." ON)
+MARK_AS_ADVANCED(OTB_USE_VISU_GUI)
+
+SET(OTB_GLU_INCLUDE_PATH "")
+IF(OTB_USE_VISU_GUI)
+
+        #-------------------------------
+        # OpenGL Library
+        #-------------------------------
+        FIND_PACKAGE(OpenGL)
+
+        IF( NOT OPENGL_FOUND )
+                MESSAGE(FATAL_ERROR "Unable to find OpenGL on your system.\nCannot build OTB Visu module without OpenGL library.\nInstall OpenGL on your system OR set OTB_USE_VISU_GUI to OFF to disable OTB Visu module generation")
+        ENDIF( NOT OPENGL_FOUND )
+        IF( NOT OPENGL_GLU_FOUND )
+                MESSAGE(FATAL_ERROR "Unable to find GLU library on your system.\nCannot build OTB Visu module without GLU library.\nInstall GLU library on your system OR set OTB_USE_VISU_GUI to OFF to disable OTB Visu module generation")
+        ENDIF( NOT OPENGL_GLU_FOUND )
+
+        IF(OPENGL_INCLUDE_DIR)
+                INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
+        ENDIF(OPENGL_INCLUDE_DIR)
+
+        #-------------------------------
+        # Display images using textures using video card acceleration
+        #-------------------------------
+        OPTION(OTB_GL_USE_ACCEL "Use video card acceleration." OFF)
+        MARK_AS_ADVANCED(OTB_GL_USE_ACCEL)
+
+        #-------------------------------
+        # FLTK Library
+        #-------------------------------
+        OPTION(OTB_USE_EXTERNAL_FLTK "Use an outside build of FLTK." OFF)
+
+        IF(OTB_USE_EXTERNAL_FLTK)
+          FIND_PACKAGE(FLTK)
+          IF(NOT FLTK_FOUND)
+            MESSAGE(FATAL_ERROR
+                  "Cannot build OTB project without FLTK. Please set FLTK_DIR or set OTB_USE_EXTERNAL_FLTK OFF to use INTERNAL FLTK.")
+          ENDIF(NOT FLTK_FOUND)
+        ELSE(OTB_USE_EXTERNAL_FLTK)
+          # Same Set as ITK
+          SET(FLTK_SOURCE_DIR ${OTB_SOURCE_DIR}/Utilities/FLTK)
+          SET(FLTK_BINARY_DIR ${OTB_BINARY_DIR}/Utilities/FLTK)
+          # Additionnal variables needed by OTB_VISU_GUI_LIBRARIES and FLTK_FLUID_EXECUTABLE
+          SET(FLTK_LIBRARIES "fltk_images;fltk;fltk_gl;fltk_forms")
+          SET(FLUID_COMMAND fluid)
+          # FLTK CMake needs a variable called JPEG_INCLUDE_DIR
+          SET(JPEG_INCLUDE_DIR ${JPEG_INCLUDE_DIRS})
+        ENDIF(OTB_USE_EXTERNAL_FLTK)
+
+        SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES}")
+        SET(FLTK_FLUID_EXECUTABLE ${FLUID_COMMAND})
+           
+        SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES};${FLTK_PLATFORM_DEPENDENT_LIBS}")
+        IF(APPLE)
+            SET(OTB_VISU_GUI_LIBRARIES "${OTB_VISU_GUI_LIBRARIES};-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
+        ENDIF(APPLE)
+               
+        IF(OTB_USE_EXTERNAL_FLTK)
+          MESSAGE(STATUS "  Using FLTK external version")
+          MESSAGE(STATUS "  FLTK includes : ${FLTK_INCLUDE_DIR}")
+          MESSAGE(STATUS "  FLTK libraries: ${OTB_VISU_GUI_LIBRARIES}")
+        ELSE(OTB_USE_EXTERNAL_FLTK)
+          MESSAGE(STATUS "  Using FLTK internal version")
+        ENDIF(OTB_USE_EXTERNAL_FLTK)
+        
+ELSE(OTB_USE_VISU_GUI)
+
+  SET(OTB_VISU_GUI_LIBRARIES "")
+  MESSAGE(STATUS "  Disabling FLTK support")
+  
+ENDIF(OTB_USE_VISU_GUI)
+
diff --git a/CMake/ImportGdal.cmake b/CMake/ImportGdal.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..2d5c20b64f9c7356e87ae692c9fa3c156bb90638
--- /dev/null
+++ b/CMake/ImportGdal.cmake
@@ -0,0 +1,151 @@
+MESSAGE(STATUS "Importing GDAL...")
+# Option for internal/external GDAL
+OPTION(OTB_USE_EXTERNAL_GDAL "Use an outside build of GDAL. (OFF is NOT IMPLEMENTED)" ON)
+MARK_AS_ADVANCED(OTB_USE_EXTERNAL_GDAL)
+
+IF(OTB_USE_EXTERNAL_GDAL)
+
+  FIND_PACKAGE(GDAL)
+
+  IF (NOT GDAL_FOUND)
+    FIND_PATH(GDAL_INCLUDE_DIR gdal.h $ENV{GDAL_INCLUDE_DIR} /usr/include/gdal)
+    FIND_LIBRARY(GDAL_LIBRARY NAMES gdal gdal1.5.0 gdal1.4.0 gdal1.3.2 PATHS /usr/lib/gdal)
+  ENDIF(NOT GDAL_FOUND)
+
+  IF (NOT GDAL_INCLUDE_DIR)
+  MESSAGE(FATAL_ERROR
+           "Cannot find GDAL include directory. Please set GDAL_INCLUDE_DIR.")
+  ENDIF (NOT GDAL_INCLUDE_DIR)
+
+  INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIR})
+
+  IF (NOT GDAL_LIBRARY)
+  MESSAGE(FATAL_ERROR
+           "Cannot find GDAL library. Please set GDAL_LIBRARY.")
+  ENDIF (NOT GDAL_LIBRARY)
+  MESSAGE(STATUS "  GDAL includes : ${GDAL_INCLUDE_DIR}")
+  MESSAGE(STATUS "  GDAL library  : ${GDAL_LIBRARY}")
+
+  # Find gdal version
+  FIND_PROGRAM(GDALCONFIG_EXECUTABLE gdal-config)
+  IF (GDALCONFIG_EXECUTABLE)
+      EXECUTE_PROCESS(COMMAND ${GDALCONFIG_EXECUTABLE} --version
+      OUTPUT_VARIABLE GDAL_VERSION
+      OUTPUT_STRIP_TRAILING_WHITESPACE)
+      MESSAGE(STATUS "  GDAL version is " ${GDAL_VERSION})
+      SET(GDAL_VERSION ${GDAL_VERSION} CACHE STRING "GDAL version" FORCE)
+      MARK_AS_ADVANCED(GDAL_VERSION)
+  ELSE (GDALCONFIG_EXECUTABLE)    
+      MESSAGE(STATUS "  gdal-config not found")
+  ENDIF (GDALCONFIG_EXECUTABLE)
+  
+
+  # Find geotiff headers
+  FIND_PATH(GEOTIFF_INCLUDE_DIRS geotiff.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include/geotiff /usr/include/libgeotiff)
+  IF (NOT GEOTIFF_INCLUDE_DIRS)
+  MESSAGE(FATAL_ERROR
+           "Cannot find geotiff headers. Please set GEOTIFF_INCLUDE_DIRS.")
+  ENDIF (NOT GEOTIFF_INCLUDE_DIRS)
+#  INCLUDE_DIRECTORIES(${GEOTIFF_INCLUDE_DIRS})
+
+  # Find tiff headers
+  FIND_PATH(TIFF_INCLUDE_DIRS tiffio.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
+  IF (NOT TIFF_INCLUDE_DIRS)
+  MESSAGE(FATAL_ERROR
+           "Cannot find libtiff headers. Please set TIFF_INCLUDE_DIRS.")
+  ENDIF (NOT TIFF_INCLUDE_DIRS)
+#  INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIRS})
+
+  # Find jpeg headers
+  FIND_PATH(JPEG_INCLUDE_DIRS jpeglib.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
+  IF (NOT JPEG_INCLUDE_DIRS)
+  MESSAGE(FATAL_ERROR
+           "Cannot find jpeg headers. Please set JPEG_INCLUDE_DIRS.")
+  ENDIF (NOT JPEG_INCLUDE_DIRS)
+  INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIRS})
+
+  # Find ogr headers
+  FIND_PATH(OGR_INCLUDE_DIRS ogrsf_frmts.h  $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
+  IF (NOT OGR_INCLUDE_DIRS)
+  MESSAGE(FATAL_ERROR
+           "Cannot find ogr headers. Please set OGR_INCLUDE_DIRS.")
+  ENDIF (NOT OGR_INCLUDE_DIRS)
+  INCLUDE_DIRECTORIES(${OGR_INCLUDE_DIRS})
+
+  # Check if ${GDAL_LIBRARY} has tiff library
+  TRY_COMPILE(GDAL_HAS_TIFF
+  ${CMAKE_CURRENT_BINARY_DIR}/CMake
+  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasTiff.cxx
+  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${TIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
+  OUTPUT_VARIABLE OUTPUT)
+  IF(GDAL_HAS_TIFF)
+  MESSAGE(STATUS "  Testing if GDAL has tiff    -- yes")
+  SET(TIFF_LIBRARY ${GDAL_LIBRARY})
+  ELSE(GDAL_HAS_TIFF)
+  MESSAGE(STATUS "  Testing if GDAL has tiff    -- no")
+  FIND_LIBRARY(TIFF_LIBRARY tiff PATHS)
+  IF (NOT TIFF_LIBRARY)
+  MESSAGE(FATAL_ERROR
+           "Cannot find tiff library. Please set TIFF_LIBRARY.")
+  ENDIF (NOT TIFF_LIBRARY)
+  ENDIF(GDAL_HAS_TIFF)
+
+  # Check if ${GDAL_LIBRARY} has geotiff library
+  TRY_COMPILE(GDAL_HAS_GEOTIFF
+  ${CMAKE_CURRENT_BINARY_DIR}/CMake
+  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasGeoTiff.cxx
+  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GEOTIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
+  OUTPUT_VARIABLE OUTPUT)
+  IF(GDAL_HAS_GEOTIFF)
+  MESSAGE(STATUS "  Testing if GDAL has geotiff -- yes")
+  SET(GEOTIFF_LIBRARY ${GDAL_LIBRARY})
+  ELSE(GDAL_HAS_GEOTIFF)
+  MESSAGE(STATUS "  Testing if GDAL has geotiff -- no")
+  FIND_LIBRARY(GEOTIFF_LIBRARY geotiff PATHS)
+  IF (NOT GEOTIFF_LIBRARY)
+  MESSAGE(FATAL_ERROR
+           "Cannot find geotiff library. Please set GEOTIFF_LIBRARY.")
+  ENDIF (NOT GEOTIFF_LIBRARY)
+  ENDIF(GDAL_HAS_GEOTIFF)
+
+  # Check if ${GDAL_LIBRARY} has jpeg library
+  TRY_COMPILE(GDAL_HAS_JPEG
+  ${CMAKE_CURRENT_BINARY_DIR}/CMake
+  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasJpeg.cxx
+  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${JPEG_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
+  OUTPUT_VARIABLE OUTPUT)
+  IF(GDAL_HAS_JPEG)
+  MESSAGE(STATUS "  Testing if GDAL has jpeg    -- yes")
+  SET(JPEG_LIBRARY ${GDAL_LIBRARY})
+  ELSE(GDAL_HAS_JPEG)
+  MESSAGE(STATUS "  Testing if GDAL has jpeg    -- no")
+  FIND_LIBRARY(JPEG_LIBRARY jpeg PATHS)
+  IF (NOT JPEG_LIBRARY)
+  MESSAGE(FATAL_ERROR
+           "Cannot find jpeg library. Please set JPEG_LIBRARY.")
+  ENDIF (NOT JPEG_LIBRARY)
+  ENDIF(GDAL_HAS_JPEG)
+
+  # Check if ${GDAL_LIBRARY} has ogr library
+  TRY_COMPILE(GDAL_HAS_OGR
+  ${CMAKE_CURRENT_BINARY_DIR}/CMake
+  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasOGR.cxx
+  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${OGR_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
+  OUTPUT_VARIABLE OUTPUT)
+  IF(GDAL_HAS_OGR)
+  MESSAGE(STATUS "  Testing if GDAL has OGR     -- yes")
+  SET(OGR_LIBRARY ${GDAL_LIBRARY})
+  ELSE(GDAL_HAS_OGR)
+  MESSAGE(STATUS "  Testing if GDAL has OGR     -- no")
+  MESSAGE(FATAL_ERROR "OGR MESSAGE: ${OUTPUT}")
+  FIND_LIBRARY(OGR_LIBRARY ogr PATHS)
+  IF (NOT OGR_LIBRARY)
+  MESSAGE(FATAL_ERROR
+           "Cannot find ogr library. Please set OGR_LIBRARY.")
+  ENDIF (NOT OGR_LIBRARY)
+  ENDIF(GDAL_HAS_OGR)
+ELSE(OTB_USE_EXTERNAL_GDAL)
+
+  MESSAGE(FATAL_ERROR "OTB_USE_EXTERNAL_GDAL=OFF is not implemented. Please set OTB_USE_EXTERNAL_GDAL to ON")
+
+ENDIF(OTB_USE_EXTERNAL_GDAL)
diff --git a/CMake/ImportGetText.cmake b/CMake/ImportGetText.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..9711e900ec0c6f4fc5a3a8c8b09221fa1800e796
--- /dev/null
+++ b/CMake/ImportGetText.cmake
@@ -0,0 +1,50 @@
+MESSAGE(STATUS "Importing GetText...")
+
+OPTION(OTB_USE_GETTEXT "Get Text Library." ON)
+
+IF(OTB_USE_GETTEXT)
+    
+    FIND_PACKAGE(Gettext)
+    IF(GETTEXT_FOUND)
+      FIND_LIBRARY(GETTEXT_LIBRARY gettextlib DOC "GetText library")
+      IF(APPLE OR WIN32)
+        FIND_LIBRARY(GETTEXT_INTL_LIBRARY intl DOC "GetText intl library")
+      ENDIF(APPLE OR WIN32)
+    
+      IF(GETTEXT_LIBRARY)
+          SET(OTB_I18N 1)
+          MESSAGE(STATUS
+                  "  GetText found, configuring internationalization")
+          SET(OTB_LANG $ENV{LANG} CACHE STRING "OTB internationalization (Experimental)")#might want to get the Locale from the system here
+          IF(NOT OTB_LANG)
+            SET(OTB_LANG "en_EN.UTF-8" CACHE STRING "OTB internationalization (Experimental)" FORCE)
+          ENDIF(NOT OTB_LANG)
+          SET(OTB_LANG_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/I18n)
+          ADD_SUBDIRECTORY(I18n)
+          FIND_PATH(GETTEXT_INCLUDE_DIR
+            libintl.h
+            DOC "Path to gettext include directory (where libintl.h can be found)")
+          MARK_AS_ADVANCED(GETTEXT_INCLUDE_DIR)
+        
+          IF(GETTEXT_INCLUDE_DIR)
+            INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
+          ENDIF(GETTEXT_INCLUDE_DIR)
+      ENDIF(GETTEXT_LIBRARY)
+      
+      #MESSAGE(STATUS "  Enabling GetText support")
+      MESSAGE(STATUS "  GetText includes: ${GETTEXT_INCLUDE_DIR}")
+      MESSAGE(STATUS "  GetText library : ${GETTEXT_LIBRARY}")
+      IF(APPLE OR WIN32)
+        MESSAGE(STATUS "  GetText intl library  : ${GETTEXT_INTL_LIBRARY}")
+      ENDIF(APPLE OR WIN32)
+    
+    ELSE(GETTEXT_FOUND)
+      SET(OTB_I18N 0)
+      MESSAGE(STATUS
+                  "  Gettext not found, internationalization will not be available")
+    ENDIF(GETTEXT_FOUND)
+    
+ELSE(OTB_USE_GETTEXT)
+    MESSAGE(STATUS "  Disabling GetText support")
+ENDIF(OTB_USE_GETTEXT)
+
diff --git a/CMake/ImportITK.cmake b/CMake/ImportITK.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..081790c7b6d01f8f6edf24691af87432fb56cb7a
--- /dev/null
+++ b/CMake/ImportITK.cmake
@@ -0,0 +1,37 @@
+MESSAGE(STATUS "Importing ITK...")
+OPTION(OTB_USE_EXTERNAL_ITK "Use an outside build of ITK." OFF)
+
+IF(OTB_USE_EXTERNAL_ITK)
+  FIND_PACKAGE(ITK)
+  IF(ITK_FOUND)
+        # Build ITK_INCLUDE_DIRS list wihout expat path
+        SET(new_list "")
+        FOREACH(files_h ${ITK_INCLUDE_DIRS})
+                IF(NOT "${files_h}" MATCHES "expat")
+                        SET(new_list "${new_list};${files_h}")
+                ENDIF(NOT "${files_h}" MATCHES "expat")
+        ENDFOREACH(files_h ${ITK_INCLUDE_DIRS})
+        SET(ITK_INCLUDE_DIRS "${new_list}")
+
+        INCLUDE(${ITK_USE_FILE})
+  ELSE(ITK_FOUND)
+        MESSAGE(FATAL_ERROR
+                  "Cannot build OTB project without ITK.  Please set ITK_DIR or set OTB_USE_EXTERNAL_ITK OFF to use INTERNAL ITK set on OTB/Utilities repository.")
+  ENDIF(ITK_FOUND)
+  
+  # Build shared libraries for otb
+  # By default, if otb use an external itk import the option from the ITK configuration
+  SET(BUILD_SHARED_LIBS ${ITK_BUILD_SHARED})
+  
+  MESSAGE(STATUS "  Using ITK external version")
+    
+ELSE(OTB_USE_EXTERNAL_ITK)
+
+
+  # Required to have proper itk headers at first run
+  SET(ITK_SOURCE_DIR ${OTB_SOURCE_DIR}/Utilities/ITK)
+  SET(ITK_BINARY_DIR ${OTB_BINARY_DIR}/Utilities/ITK)
+  MESSAGE(STATUS "  Using ITK internal version")
+  
+ENDIF(OTB_USE_EXTERNAL_ITK)
+
diff --git a/CMake/ImportJPEG2000.cmake b/CMake/ImportJPEG2000.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..46d776bbc8711b8e103ce447780b1b6bc2698fa1
--- /dev/null
+++ b/CMake/ImportJPEG2000.cmake
@@ -0,0 +1,42 @@
+MESSAGE(STATUS "Importing Jpeg2000...")
+# Use the openjpeg library.
+OPTION(OTB_USE_JPEG2000 "Use to support jpeg2000 image file format." ON)
+
+# JPEG2000 specification control
+SET(OTB_COMPILE_JPEG2000 0)
+IF( OTB_USE_JPEG2000 )
+  SET(OTB_COMPILE_JPEG2000 1)
+  IF(OTB_USE_EXTERNAL_ITK)
+        MESSAGE(STATUS "  WARNING: Due to conflicting libraries, jpeg2000 support is disabled when using external ITK.")
+        SET(OTB_COMPILE_JPEG2000 0)
+  ENDIF(OTB_USE_EXTERNAL_ITK)
+  IF(CMAKE_GENERATOR MATCHES "^Visual Studio 7$")
+        MESSAGE(STATUS "  WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
+        SET(OTB_COMPILE_JPEG2000 0)
+  ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio 7$")
+  IF(CMAKE_GENERATOR MATCHES "^Visual Studio 7 .NET 2003$")
+        MESSAGE(STATUS "  WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
+        SET(OTB_COMPILE_JPEG2000 0)
+  ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio 7 .NET 2003$")
+  IF(CYGWIN)
+        MESSAGE(STATUS "  WARNING: For cygwin, jpeg2000 support is disabled.")
+        SET(OTB_COMPILE_JPEG2000 0)
+  ENDIF(CYGWIN)
+  
+  IF(OTB_COMPILE_JPEG2000)
+    MESSAGE(STATUS "  Enabling Jpeg2000 support (internal)")
+  ELSE(OTB_COMPILE_JPEG2000)
+    MESSAGE(STATUS "  Disabling Jpeg2000 support")
+  ENDIF(OTB_COMPILE_JPEG2000)
+  
+ELSE( OTB_USE_JPEG2000 )
+    MESSAGE(STATUS "  Disabling Jpeg2000 support")
+ENDIF( OTB_USE_JPEG2000 )
+
+# Check jpeg2000 support
+IF(OTB_COMPILE_JPEG2000)
+  ADD_DEFINITIONS(-DOTB_COMPILE_JPEG2000 -DUSE_OPJ_DEPRECATED)
+  IF(NOT BUILD_SHARED_LIBS)
+        ADD_DEFINITIONS(-DOPJ_STATIC)
+  ENDIF(NOT BUILD_SHARED_LIBS)
+ENDIF(OTB_COMPILE_JPEG2000)
diff --git a/CMake/ImportLibLAS.cmake b/CMake/ImportLibLAS.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..3a4119154ffc2996a04ce8a06a99112763396b9f
--- /dev/null
+++ b/CMake/ImportLibLAS.cmake
@@ -0,0 +1,35 @@
+MESSAGE(STATUS "Importing LibLAS...")
+# Use the liblas library (do not link on solaris)
+OPTION(OTB_USE_LIBLAS "Use liblas library to support Lidar data format." ON)
+MARK_AS_ADVANCED(OTB_USE_LIBLAS)
+
+IF(OTB_USE_LIBLAS)
+    
+    OPTION(OTB_USE_EXTERNAL_LIBLAS "Use an outside build of LibLAS (Lidar data)." OFF)
+    MARK_AS_ADVANCED(OTB_USE_EXTERNAL_LIBLAS)
+    
+    IF(OTB_USE_EXTERNAL_LIBLAS)
+        FIND_PATH(LIBLAS_INCLUDE_DIR liblas.hpp)
+        IF(LIBLAS_INCLUDE_DIR)
+          INCLUDE_DIRECTORIES(BEFORE ${LIBLAS_INCLUDE_DIR})
+        ENDIF(LIBLAS_INCLUDE_DIR)
+        
+        FIND_LIBRARY(LIBLAS_LIBRARY NAMES liblas)
+        IF(LIBLAS_LIBRARY)
+          LINK_DIRECTORIES( ${LIBLAS_LIBRARY} )
+        ENDIF(LIBLAS_LIBRARY)
+    ENDIF(OTB_USE_EXTERNAL_LIBLAS)
+    
+    IF(OTB_USE_EXTERNAL_LIBLAS)
+      MESSAGE(STATUS "  Using LibLAS external version")
+      MESSAGE(STATUS "  LibLAS includes : ${LIBLAS_INCLUDE_DIR}")
+      MESSAGE(STATUS "  LibLAS library  : ${LIBLAS_LIBRARY}")
+    ELSE(OTB_USE_EXTERNAL_LIBLAS)
+      MESSAGE(STATUS "  Using LibLAS internal version")
+    ENDIF(OTB_USE_EXTERNAL_LIBLAS)
+
+ELSE(OTB_USE_LIBLAS)
+
+    MESSAGE(STATUS "  Disabling LibLAS support")
+    
+ENDIF(OTB_USE_LIBLAS)
\ No newline at end of file
diff --git a/CMake/ImportMapnik.cmake b/CMake/ImportMapnik.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..e230b12bcbf13d83ca09d34be1c51b27acc6ab9e
--- /dev/null
+++ b/CMake/ImportMapnik.cmake
@@ -0,0 +1,54 @@
+MESSAGE(STATUS "Importing Mapnik...")
+OPTION(OTB_USE_MAPNIK "Use mapnik library." OFF)
+MARK_AS_ADVANCED(OTB_USE_MAPNIK)
+
+IF(OTB_USE_MAPNIK)
+        IF(NOT OTB_USE_EXTERNAL_BOOST)
+          MESSAGE(FATAL_ERROR "You need to set OTB_USE_EXTERNAL_BOOST to ON when using MAPNIK")
+        ENDIF(NOT OTB_USE_EXTERNAL_BOOST)
+
+        FIND_PATH(MAPNIK_INCLUDE_DIR mapnik/map.hpp PATHS)
+        MARK_AS_ADVANCED(MAPNIK_INCLUDE_DIR)
+        IF (NOT MAPNIK_INCLUDE_DIR)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find MAPNIK include directory. Please set MAPNIK_INCLUDE_DIR or set OTB_USE_MAPNIK OFF.")
+        ENDIF (NOT MAPNIK_INCLUDE_DIR)
+
+        FIND_PATH(FREETYPE2_INCLUDE_DIR freetype/freetype.h PATHS /usr/include/freetype2)
+        MARK_AS_ADVANCED(FREETYPE2_INCLUDE_DIR)
+        IF (NOT FREETYPE2_INCLUDE_DIR)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find FREETYPE2 include directory. Please set  or set OTB_USE_MAPNIK OFF.")
+        ENDIF (NOT FREETYPE2_INCLUDE_DIR)
+
+        FIND_LIBRARY(MAPNIK_LIBRARY mapnik )
+        MARK_AS_ADVANCED(MAPNIK_LIBRARY)
+        IF (NOT MAPNIK_LIBRARY)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find MAPNIK library. Please set MAPNIK_LIBRARY or set OTB_USE_MAPNIK OFF.")
+        ENDIF (NOT MAPNIK_LIBRARY)
+
+        # libicuuc is a unicode library mapnik relies on.
+        # since libicuuc version 1.42, we need to link against it when linking against mapnik
+        # otherwise we get undefined symbol error
+        FIND_LIBRARY(ICUUC_LIBRARY icuuc )
+        MARK_AS_ADVANCED(ICUUC_LIBRARY)
+        IF (NOT ICUUC_LIBRARY)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find ICUUC library, needed by MAPNIK. Please set ICUUC_LIBRARY or set OTB_USE_MAPNIK OFF.")
+        ENDIF (NOT ICUUC_LIBRARY)
+
+        # Add compiler option
+        ADD_DEFINITIONS(-DOTB_USE_MAPNIK)
+
+        INCLUDE_DIRECTORIES(${MAPNIK_INCLUDE_DIR})
+        
+        MESSAGE(STATUS "  Enabling Mapnik support")
+        MESSAGE(STATUS "  Mapnik includes : ${MAPNIK_INCLUDE_DIR}")
+        MESSAGE(STATUS "  Mapnik library  : ${MAPNIK_LIBRARY}")
+        
+ELSE(OTB_USE_MAPNIK)
+
+    MESSAGE(STATUS "  Disabling Mapnik support")
+    
+ENDIF(OTB_USE_MAPNIK)
diff --git a/CMake/ImportOpenThreads.cmake b/CMake/ImportOpenThreads.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..6ab5a5876f4fe3173c6ef6104155145f6724c37e
--- /dev/null
+++ b/CMake/ImportOpenThreads.cmake
@@ -0,0 +1,34 @@
+MESSAGE(STATUS "Importing OpenThreads...")
+#-----------------------------------------------------------------------------
+# Option for OpenThreads (necessary because used by the OSSIM library)
+# Find OpenThread library
+IF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
+        FIND_PACKAGE(OpenThreads)
+ELSE(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
+        INCLUDE(${OTB_SOURCE_DIR}/CMake/FindOpenThreads.cmake)
+ENDIF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
+
+SET(OTB_USE_EXTERNAL_OPENTHREADS ON CACHE INTERNAL "")
+IF(OPENTHREADS_FOUND)
+
+        INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
+        LINK_DIRECTORIES( ${OPENTHREADS_LIBRARY} )
+                
+        MESSAGE(STATUS "  Using OpenThreads external version")
+        MESSAGE(STATUS "  OpenThreads includes : ${OPENTHREADS_INCLUDE_DIR}")
+        MESSAGE(STATUS "  OpenThreads library  : ${OPENTHREADS_LIBRARY}")
+
+ELSE(OPENTHREADS_FOUND)
+
+        ADD_DEFINITIONS(-DOTB_USE_INTERNAL_OPENTHREADS)
+        SET(OTB_USE_EXTERNAL_OPENTHREADS OFF)
+        SET(OPENTHREADS_INCLUDE_DIR "${OTB_SOURCE_DIR}/Utilities/otbopenthreads/OpenThreads/include")
+        SET(OPENTHREADS_LIBRARY "OpenThreads" )
+        INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
+        IF(NOT BUILD_SHARED_LIBS)
+          ADD_DEFINITIONS(-DOT_LIBRARY_STATIC)
+        ENDIF(NOT BUILD_SHARED_LIBS)
+        
+        MESSAGE(STATUS "  Using OpenThreads internal version")
+        
+ENDIF(OPENTHREADS_FOUND)
\ No newline at end of file
diff --git a/CMake/ImportPqxx.cmake b/CMake/ImportPqxx.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..a3c416a155073da3194bdfecce928ee370dc216e
--- /dev/null
+++ b/CMake/ImportPqxx.cmake
@@ -0,0 +1,42 @@
+MESSAGE(STATUS "Importing Pqxx...")
+OPTION(OTB_USE_PQXX "Use pqxx library (EXPERIMENTAL)." OFF)
+MARK_AS_ADVANCED(OTB_USE_PQXX)
+IF(OTB_USE_PQXX)
+
+        FIND_PATH(PQXX_INCLUDE_DIR pqxx/pqxx PATHS)
+        MARK_AS_ADVANCED(PQXX_INCLUDE_DIR)
+        IF (NOT PQXX_INCLUDE_DIR)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find PQXX include directory. Please set PQXX_INCLUDE_DIR or SET OTB_USE_PQXX OFF.")
+        ENDIF (NOT PQXX_INCLUDE_DIR)
+
+
+        FIND_LIBRARY(PQXX_LIBRARY pqxx )
+        MARK_AS_ADVANCED(PQXX_LIBRARY)
+        IF (NOT PQXX_LIBRARY)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find PQXX library. Please set PQXX_LIBRARY or SET OTB_USE_PQXX OFF.")
+        ENDIF (NOT PQXX_LIBRARY)
+
+        FIND_LIBRARY(PQ_LIBRARY pq )
+        MARK_AS_ADVANCED(PQ_LIBRARY)
+        IF (NOT PQ_LIBRARY)
+                MESSAGE(FATAL_ERROR
+                        "Cannot find PQ library. Please set PQ_LIBRARY or SET OTB_USE_PQXX OFF.")
+        ENDIF (NOT PQ_LIBRARY)
+
+
+        # Add compiler option
+        ADD_DEFINITIONS(-DOTB_USE_PQXX)
+
+        INCLUDE_DIRECTORIES(${PQXX_INCLUDE_DIR})
+        
+        MESSAGE(STATUS "  Enabling Pqxx support")
+        MESSAGE(STATUS "  Pqxx includes : ${PQXX_INCLUDE_DIR}")
+        MESSAGE(STATUS "  Pqxx library  : ${PQXX_LIBRARY}")
+        
+ELSE(OTB_USE_PQXX)
+
+    MESSAGE(STATUS "  Disabling Pqxx support")
+
+ENDIF(OTB_USE_PQXX)
diff --git a/CMake/OTBCPack.cmake b/CMake/OTBCPack.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..2caa1e7c5b78820726d9363caec07361149be594
--- /dev/null
+++ b/CMake/OTBCPack.cmake
@@ -0,0 +1,54 @@
+#-----------------------------------------------------------------------------
+# Set up CPack support, to be able to distribute OTB binary packages
+#
+OPTION(OTB_USE_CPACK "Generate installer using CPack" OFF)
+MARK_AS_ADVANCED(OTB_USE_CPACK)
+
+IF(OTB_USE_CPACK)
+
+    INCLUDE(InstallRequiredSystemLibraries)
+    
+    SET(CPACK_PACKAGE_NAME "OTB" CACHE STRING "Package name")
+    MARK_AS_ADVANCED(CPACK_PACKAGE_NAME)
+    
+    SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Orfeo Toolbox")
+    MARK_AS_ADVANCED(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+    
+    SET(CPACK_PACKAGE_VERSION  "${OTB_VERSION_STRING}")
+    SET(CPACK_PACKAGE_VERSION_MAJOR "${OTB_VERSION_MAJOR}")
+    SET(CPACK_PACKAGE_VERSION_MINOR "${OTB_VERSION_MINOR}")
+    SET(CPACK_PACKAGE_VERSION_PATCH "${OTB_VERSION_PATCH}")
+    
+    SET(CPACK_PACKAGE_CONTACT "contact@orfeo-toolbox.org" CACHE STRING  "Orfeo toolbox contact email")
+    
+    SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Description.txt")
+    
+    #Debian specific
+    SET(DEBIAN_PACKAGE_MAINTAINER  "debian@orfeo-toolbox.org" CACHE STRING  "Debian package maintainer email")
+    SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libgdal1-1.5.0 (>= 1.5.1-0), libfltk1.1 (>= 1.1.7-3), libcurl3 (>=7.15.5-1etch1), libfftw3-3 (>=3.1.2-3.1)" CACHE STRING "Debian package dependance" )
+    SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" CACHE STRING "arch")
+    MARK_AS_ADVANCED(CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
+    SET(CPACK_DEBIAN_PACKAGE_NAME "libotb" CACHE STRING "Debian package name")
+    
+    SET(CPACK_PACKAGE_INSTALL_DIRECTORY "OrfeoToolbox-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
+    
+    SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright/OTBCopyright.txt")
+    
+    FILE(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
+    FILE(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_DEBIAN_PACKAGE_DESCRIPTION)
+    
+    IF(WIN32 AND NOT UNIX AND NOT CYGWIN)
+    #Find gdal dll files, localized in the GDAL_LIBRARY directory
+    GET_FILENAME_COMPONENT(GDAL_LIB_DIR "${GDAL_LIBRARY}" PATH )
+    SET(GDAL_LIB_DIR "${GDAL_LIB_DIR}/" )
+    INSTALL(DIRECTORY ${GDAL_LIB_DIR}
+            DESTINATION                 bin
+            FILES_MATCHING  PATTERN     "*.dll" )
+    INSTALL(DIRECTORY ${GDAL_LIB_DIR}
+            DESTINATION                 lib
+            FILES_MATCHING  PATTERN     "*.lib" )
+    ENDIF(WIN32 AND NOT UNIX AND NOT CYGWIN)
+    
+    INCLUDE(CPack)
+
+ENDIF(OTB_USE_CPACK)
diff --git a/CMake/PreventInstallOnBuildTree.cmake b/CMake/PreventInstallOnBuildTree.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..afcc89c39003f5b7773afddd46d6e0d580c1a853
--- /dev/null
+++ b/CMake/PreventInstallOnBuildTree.cmake
@@ -0,0 +1,15 @@
+# Make sure the user does not try to install on top of the build tree.
+IF(WIN32 OR APPLE OR UNIX)
+  STRING(TOLOWER "${CMAKE_INSTALL_PREFIX}" _PREFIX)
+  STRING(TOLOWER "${OTB_BINARY_DIR}" _BUILD)
+ELSE(WIN32 OR APPLE OR UNIX)
+  SET(_PREFIX "${CMAKE_INSTALL_PREFIX}")
+  SET(_BUILD "${OTB_BINARY_DIR}")
+ENDIF(WIN32 OR APPLE OR UNIX)
+IF("${_PREFIX}" STREQUAL "${_BUILD}")
+  MESSAGE(FATAL_ERROR
+    "The current CMAKE_INSTALL_PREFIX points at the build tree:\n"
+    "  ${CMAKE_INSTALL_PREFIX}\n"
+    "This is not supported."
+    )
+ENDIF("${_PREFIX}" STREQUAL "${_BUILD}")
diff --git a/CMake/SourceStatus.cmake b/CMake/SourceStatus.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..1f52da15885fc5a39015762fedb157f1c1c7b0bb
--- /dev/null
+++ b/CMake/SourceStatus.cmake
@@ -0,0 +1,19 @@
+FIND_PACKAGE(Mercurial)
+IF(Mercurial_FOUND)
+  MESSAGE(STATUS "Repository status :")
+  Mercurial_WC_IDENTIFY(${PROJECT_SOURCE_DIR} OTB)
+  MESSAGE(STATUS "  Mercurial version is ${Mercurial_VERSION_HG}")
+  MESSAGE(STATUS "  Repository revision is ${OTB_WC_REVISION}")
+  SET(OTB_WC_REVISION ${OTB_WC_REVISION} CACHE STRING "Repository version" FORCE)
+  MARK_AS_ADVANCED(OTB_WC_REVISION)
+  IF(OTB_WC_STATUS)
+    MESSAGE(STATUS "  Local file modifications:")
+    STRING(REPLACE "\n" "\n--     " OTB_WC_STATUS_PRETTYPRINT "    ${OTB_WC_STATUS}")
+    MESSAGE(STATUS "${OTB_WC_STATUS_PRETTYPRINT}")
+  ELSE(OTB_WC_STATUS)
+    MESSAGE(STATUS "  No files modified locally")
+  ENDIF(OTB_WC_STATUS)
+  STRING(REGEX REPLACE "\n" ";" OTB_WC_STATUS "${OTB_WC_STATUS}")
+  SET(OTB_WC_STATUS ${OTB_WC_STATUS} CACHE STRING "Repository status" FORCE)
+  MARK_AS_ADVANCED(OTB_WC_STATUS)
+ENDIF(Mercurial_FOUND)
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5df6911320d889f64982a409e7c7e6734214d393..71576f73393a47564aab388a80bada1379064564 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,50 +22,7 @@ INCLUDE_REGULAR_EXPRESSION("^(otb|itk|vtk|vnl|vcl|vxl|f2c|netlib|ce|itpack|DICOM
 SOURCE_GROUP("XML Files" REGULAR_EXPRESSION "[.]xml$")
 INCLUDE(CMakeDependentOption)
 
-# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
-# warnings
-IF(WIN32)
-    IF(NOT CYGWIN)
-      IF(NOT MINGW)
-        IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
-          ADD_DEFINITIONS(
-            -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
-            -D_CRT_IS_WCTYPE_NO_DEPRECATE
-            -D_CRT_MANAGED_FP_NO_DEPRECATE
-            -D_CRT_NONSTDC_NO_DEPRECATE
-            -D_CRT_SECURE_NO_DEPRECATE
-            -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
-            -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
-            -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
-            -D_CRT_VCCLRIT_NO_DEPRECATE
-            -D_SCL_SECURE_NO_DEPRECATE
-            )
-        ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
-      ENDIF(NOT MINGW)
-    ENDIF(NOT CYGWIN)
-ENDIF(WIN32)
-# __CYGWIN__ must be define for ossim (ex: ossimCommon.h, isnan definition, .. )
-#IF(CYGWIN)
-#  ADD_DEFINITIONS(-D__CYGWIN__)
-#ENDIF(CYGWIN)
-
-# If CMake is the version we're expecting, don't show the
-# CMAKE_BACKWARDS_COMPATIBILITY option. If the version is higher than the
-# minimal version required, then show the backward compatibility option.
-IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" MATCHES "^2\\.4$")
-  MARK_AS_ADVANCED(FORCE CMAKE_BACKWARDS_COMPATIBILITY)
-ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" MATCHES "^2\\.4$")
-  MARK_AS_ADVANCED(CLEAR CMAKE_BACKWARDS_COMPATIBILITY)
-ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" MATCHES "^2\\.4$")
-
-#-----------------------------------------------------------------------------
-# OTB option to access large file (> 4Go).
-ADD_DEFINITIONS(
-	-D_LARGEFILE_SOURCE
-	-D_FILE_OFFSET_BITS=64
-	-D_LARGEFILE64_SOURCE
-	-D_LARGE_FILES
-	)
+INCLUDE(SourceStatus)
 
 #-----------------------------------------------------------------------------
 # OTB version number.  An even minor number corresponds to releases.
@@ -73,670 +30,99 @@ SET(OTB_VERSION_MAJOR "3")
 SET(OTB_VERSION_MINOR "7")
 SET(OTB_VERSION_PATCH "0")
 
-FIND_PACKAGE(Mercurial)
-IF(Mercurial_FOUND)
-  Mercurial_WC_IDENTIFY(${PROJECT_SOURCE_DIR} OTB)
-  MESSAGE(STATUS "Mercurial version is ${Mercurial_VERSION_HG}")
-  MESSAGE(STATUS "Repository revision is ${OTB_WC_REVISION}")
-  SET(OTB_WC_REVISION ${OTB_WC_REVISION} CACHE STRING "Repository version" FORCE)
-  MARK_AS_ADVANCED(OTB_WC_REVISION)
-  IF(OTB_WC_STATUS)
-    MESSAGE(STATUS "Local file modifications:")
-    MESSAGE(STATUS ${OTB_WC_STATUS})
-  ELSE(OTB_WC_STATUS)
-    MESSAGE(STATUS "No files modified locally")
-  ENDIF(OTB_WC_STATUS)
-  STRING(REGEX REPLACE "\n" ";" OTB_WC_STATUS "${OTB_WC_STATUS}")
-  SET(OTB_WC_STATUS ${OTB_WC_STATUS} CACHE STRING "Repository status" FORCE)
-  MARK_AS_ADVANCED(OTB_WC_STATUS)
-ENDIF(Mercurial_FOUND)
-
 # Version string should not include patch level.  The major.minor is
 # enough to distinguish available features of the toolkit.
 SET(OTB_VERSION_STRING "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH}")
 
-OPTION(BUILD_TESTING "Build testing." OFF)
-
-#-----------------------------------------------------------------------------
-# OTB build configuration options.
-IF(WIN32)
-# do not build shared lib under windows
-SET(BUILD_SHARED_LIBS OFF)
-MESSAGE("Disabling build shared lib option on windows like OS.")
-ELSE(WIN32)
-OPTION(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON)
-ENDIF(WIN32)
-SET(OTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
-
 IF(NOT OTB_NO_LIBRARY_VERSION)
   # This setting of SOVERSION assumes that any API change
   # will increment either the minor or major version number of OTB.
   SET(OTB_LIBRARY_PROPERTIES
       VERSION   "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH}"
-      SOVERSION "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}"
-     )
+      SOVERSION "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
 ENDIF(NOT OTB_NO_LIBRARY_VERSION)
 
-SET(OTB_BUILD_PEDANTIC OFF CACHE BOOL
-    "Choose compilation in pedantic or relaxed mode")
+#-----------------------------------------------------------------------------
+# Test for some required system information.
+INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
+INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)
+
+#-----------------------------------------------------------------------------
+# Configure Dart testing support.  This should be done before any
+# MESSAGE(FATAL_ERROR ...) commands are invoked.
+INCLUDE(${CMAKE_ROOT}/Modules/Dart.cmake)
+MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
+ENABLE_TESTING()
+IF(BUILD_TESTING)
+  SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
+  MARK_AS_ADVANCED(BUILDNAME)
+ENDIF(BUILD_TESTING)
 
-IF(WIN32)
-  IF (MSVC)
-    IF(OTB_BUILD_PEDANTIC)
-      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
-    ENDIF(OTB_BUILD_PEDANTIC)
+INCLUDE(CommonDefinitions)
 
-    IF (MSVC80)
-      ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
-      ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNING)
-    ENDIF(MSVC80)
-  ENDIF(MSVC)
-ELSE(WIN32)
-  IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
-    IF(OTB_BUILD_PEDANTIC)
-      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
-    ENDIF(OTB_BUILD_PEDANTIC)
-  ENDIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
-ENDIF(WIN32)
+OPTION(BUILD_TESTING  "Build testing." OFF)
+OPTION(BUILD_EXAMPLES "Build the Examples directory." OFF)
 
+#-----------------------------------------------------------------------------
+# Option to activate deprecated classes
 OPTION(OTB_USE_DEPRECATED "Turn on the use and test of deprecated classes" OFF)
 MARK_AS_ADVANCED(OTB_USE_DEPRECATED)
 
-
 #-----------------------------------------------------------------------------
-# Output directories.
-
-#       IF(NOT LIBRARY_OUTPUT_PATH)
-SET (LIBRARY_OUTPUT_PATH ${OTB_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
-#       ENDIF(NOT LIBRARY_OUTPUT_PATH)
-IF(NOT EXECUTABLE_OUTPUT_PATH)
-   SET (EXECUTABLE_OUTPUT_PATH ${OTB_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
-ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
-
-MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
-
-SET(OTB_LIBRARY_PATH "${LIBRARY_OUTPUT_PATH}")
-SET(OTB_EXECUTABLE_PATH "${EXECUTABLE_OUTPUT_PATH}")
-SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
+# SHOW_ALL_MSG_DEBUG option
+OPTION(OTB_SHOW_ALL_MSG_DEBUG "OTB developers : Show all messages (debug, dev, etc...) use only for otb developers." OFF)
+MARK_AS_ADVANCED(OTB_SHOW_ALL_MSG_DEBUG)
 
 #-----------------------------------------------------------------------------
-
-# Use the openjpeg library.
-OPTION(OTB_USE_JPEG2000 "Use to support jpeg2000 image file format." ON)
+# Option to define streaming activation in applications
+# Use by otbConfigure.h.in
+# Note: 8*4000*4000 = 128000000 (double 4000x4000 image)
+SET(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING 128000000 CACHE STRING "Image size to activate using streaming for applications.")
+MARK_AS_ADVANCED(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING)
+SET(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING 128000000 CACHE STRING "Max size buffer for streaming.")
+MARK_AS_ADVANCED(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING)
 
 #-----------------------------------------------------------------------------
-
-# Use the liblas library (do not link on solaris)
-OPTION(OTB_USE_LIBLAS "Use liblas library to support Lidar data format." ON)
-MARK_AS_ADVANCED(OTB_USE_LIBLAS)
-
-OPTION(OTB_USE_EXTERNAL_LIBLAS "Use an outside build of LibLAS (Lidar data)." OFF)
-MARK_AS_ADVANCED(OTB_USE_EXTERNAL_LIBLAS)
-
-IF(OTB_USE_EXTERNAL_LIBLAS)
-    FIND_PATH(LIBLAS_INCLUDE_DIR liblas.hpp)
-    IF(LIBLAS_INCLUDE_DIR)
-    INCLUDE_DIRECTORIES(BEFORE ${LIBLAS_INCLUDE_DIR})
-    ENDIF(LIBLAS_INCLUDE_DIR)
-    
-    FIND_LIBRARY(LIBLAS_LIBRARY NAMES liblas)
-    IF(LIBLAS_LIBRARY)
-    LINK_DIRECTORIES( ${LIBLAS_LIBRARY} )
-    ENDIF(LIBLAS_LIBRARY)
-ENDIF(OTB_USE_EXTERNAL_LIBLAS)
-
-# FIND EXTERNAL LIBRAIRIES USE
-
-#-------------------------------
-# EXPAT Library
-#-------------------------------
-
-FIND_PACKAGE(EXPAT)
-IF(EXPAT_FOUND)
-  OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." ON)
-ELSE(EXPAT_FOUND)
-  OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." OFF)
-ENDIF(EXPAT_FOUND)
-
-MARK_AS_ADVANCED(OTB_USE_EXTERNAL_EXPAT)
-
-IF(OTB_USE_EXTERNAL_EXPAT)
-    FIND_PACKAGE(EXPAT)
-    IF(EXPAT_FOUND)
-        # Control expat compatibility
-        INCLUDE_DIRECTORIES(BEFORE ${EXPAT_INCLUDE_DIR})
-        LINK_DIRECTORIES( ${EXPAT_LIBRARY} )
-    ELSE(EXPAT_FOUND)
-        MESSAGE(FATAL_ERROR
-                  "Cannot build OTB project without lib EXPAT.  Please set EXPAT_DIR or set OTB_USE_EXTERNAL_EXPAT OFF to use INTERNAL EXPAT set on OTB/Utilities repository.")
-    ENDIF(EXPAT_FOUND)
-ELSE(OTB_USE_EXTERNAL_EXPAT)
-        ADD_DEFINITIONS(-DOTB_USE_INTERNAL_EXPAT)
-        INCLUDE_DIRECTORIES(BEFORE "${OTB_SOURCE_DIR}/Utilities/otbexpat")
-        INCLUDE_DIRECTORIES(BEFORE "${OTB_BINARY_DIR}/Utilities/otbexpat")
-	IF(NOT BUILD_SHARED_LIBS)
-        	ADD_DEFINITIONS(-DXML_STATIC)
-        ENDIF(NOT BUILD_SHARED_LIBS)
-ENDIF(OTB_USE_EXTERNAL_EXPAT)
-
-#-------------------------------
-# ITK Library
-#-------------------------------
-
-OPTION(OTB_USE_EXTERNAL_ITK "Use an outside build of ITK." OFF)
-IF(OTB_USE_EXTERNAL_ITK)
-  FIND_PACKAGE(ITK)
-  IF(ITK_FOUND)
-        # Builf ITK_INCLUDE_DIRS list wihout expat path
-        SET(new_list "")
-        FOREACH(files_h ${ITK_INCLUDE_DIRS})
-                IF(NOT "${files_h}" MATCHES "expat")
-                        SET(new_list "${new_list};${files_h}")
-                ENDIF(NOT "${files_h}" MATCHES "expat")
-        ENDFOREACH(files_h ${ITK_INCLUDE_DIRS})
-        SET(ITK_INCLUDE_DIRS "${new_list}")
-
-        INCLUDE(${ITK_USE_FILE})
-  ELSE(ITK_FOUND)
-        MESSAGE(FATAL_ERROR
-                  "Cannot build OTB project without ITK.  Please set ITK_DIR or set OTB_USE_EXTERNAL_ITK OFF to use INTERNAL ITK set on OTB/Utilities repository.")
-  ENDIF(ITK_FOUND)
-  #Build shared libraries for otb
-  #By default, if otb use an external itk import the option from the ITK configuration
-  SET(BUILD_SHARED_LIBS ${ITK_BUILD_SHARED})
-ELSE(OTB_USE_EXTERNAL_ITK)
-# Required to have proper itk headers at first run
-SET(ITK_SOURCE_DIR ${OTB_SOURCE_DIR}/Utilities/ITK)
-SET(ITK_BINARY_DIR ${OTB_BINARY_DIR}/Utilities/ITK)
-ENDIF(OTB_USE_EXTERNAL_ITK)
-
-
-# JPEG2000 specification control
-SET(OTB_COMPILE_JPEG2000 0)
-IF( OTB_USE_JPEG2000 )
-  SET(OTB_COMPILE_JPEG2000 1)
-  IF(OTB_USE_EXTERNAL_ITK)
-        MESSAGE(STATUS "WARNING: Due to conflicting libraries, jpeg2000 support is disabled when using external ITK.")
-        SET(OTB_COMPILE_JPEG2000 0)
-  ENDIF(OTB_USE_EXTERNAL_ITK)
-  IF(CMAKE_GENERATOR MATCHES "^Visual Studio 7$")
-        MESSAGE(STATUS "WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
-        SET(OTB_COMPILE_JPEG2000 0)
-  ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio 7$")
-  IF(CMAKE_GENERATOR MATCHES "^Visual Studio 7 .NET 2003$")
-        MESSAGE(STATUS "WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
-        SET(OTB_COMPILE_JPEG2000 0)
-  ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio 7 .NET 2003$")
-  IF(CYGWIN)
-        MESSAGE(STATUS "WARNING: For cygwin, jpeg2000 support is disabled.")
-        SET(OTB_COMPILE_JPEG2000 0)
-  ENDIF(CYGWIN)
-
-ENDIF( OTB_USE_JPEG2000 )
-# Check jpeg2000 support
-IF(OTB_COMPILE_JPEG2000)
-  ADD_DEFINITIONS(-DOTB_COMPILE_JPEG2000 -DUSE_OPJ_DEPRECATED)
-  IF(NOT BUILD_SHARED_LIBS)
-        ADD_DEFINITIONS(-DOPJ_STATIC)
-  ENDIF(NOT BUILD_SHARED_LIBS)
-ENDIF(OTB_COMPILE_JPEG2000)
+# Option for generate Patented examples
+OPTION(OTB_USE_PATENTED "Build patented examples. ITK must be generated whith patented option (ITK_USE_PATENTED = ON)." OFF)
+MARK_AS_ADVANCED(OTB_USE_PATENTED)
 
 #-----------------------------------------------------------------------------
-# Option for OpenThreads (necessary because used by the new version of OSSIM library)
-# Find OpenThread library
-IF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
-        FIND_PACKAGE(OpenThreads)
-ELSE(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
-        INCLUDE(${OTB_SOURCE_DIR}/CMake/FindOpenThreads.cmake)
-ENDIF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
-
-SET(OTB_USE_EXTERNAL_OPENTHREADS ON CACHE INTERNAL "")
-IF(OPENTHREADS_FOUND)
-        INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
-        LINK_DIRECTORIES( ${OPENTHREADS_LIBRARY} )
-ELSE(OPENTHREADS_FOUND)
-        ADD_DEFINITIONS(-DOTB_USE_INTERNAL_OPENTHREADS)
-        SET(OTB_USE_EXTERNAL_OPENTHREADS OFF)
-        SET(OPENTHREADS_INCLUDE_DIR "${OTB_SOURCE_DIR}/Utilities/otbopenthreads/OpenThreads/include")
-        SET(OPENTHREADS_LIBRARY "OpenThreads" )
-        INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
-	IF(NOT BUILD_SHARED_LIBS)
-         ADD_DEFINITIONS(-DOT_LIBRARY_STATIC)
-        ENDIF(NOT BUILD_SHARED_LIBS)
-ENDIF(OPENTHREADS_FOUND)
-
-IF(NOT BUILD_SHARED_LIBS)
-  ADD_DEFINITIONS(-DOSSIM_STATIC)
-ENDIF(NOT BUILD_SHARED_LIBS)
-
-#-------------------------------
-# GDAL Library
-#-------------------------------
-
-# Option for internal/external GDAL
-OPTION(OTB_USE_EXTERNAL_GDAL "Use an outside build of GDAL. (OFF is NOT IMPLEMENTED)" ON)
-MARK_AS_ADVANCED(OTB_USE_EXTERNAL_GDAL)
-
-IF(OTB_USE_EXTERNAL_GDAL)
-
-  FIND_PACKAGE(GDAL)
-
-  IF (NOT GDAL_FOUND)
-    FIND_PATH(GDAL_INCLUDE_DIR gdal.h $ENV{GDAL_INCLUDE_DIR} /usr/include/gdal)
-    FIND_LIBRARY(GDAL_LIBRARY NAMES gdal gdal1.5.0 gdal1.4.0 gdal1.3.2 PATHS /usr/lib/gdal)
-  ENDIF(NOT GDAL_FOUND)
-
-  IF (NOT GDAL_INCLUDE_DIR)
-  MESSAGE(FATAL_ERROR
-           "Cannot find GDAL include directory. Please set GDAL_INCLUDE_DIR.")
-  ENDIF (NOT GDAL_INCLUDE_DIR)
-
-  INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIR})
-
-  IF (NOT GDAL_LIBRARY)
-  MESSAGE(FATAL_ERROR
-           "Cannot find GDAL library. Please set GDAL_LIBRARY.")
-  ENDIF (NOT GDAL_LIBRARY)
-  MESSAGE(STATUS "GDAL library found: ${GDAL_LIBRARY}")
-
-  # Find gdal version
-  FIND_PROGRAM(GDALCONFIG_EXECUTABLE gdal-config)
-  IF (GDALCONFIG_EXECUTABLE)
-      EXECUTE_PROCESS(COMMAND ${GDALCONFIG_EXECUTABLE} --version
-      OUTPUT_VARIABLE GDAL_VERSION
-      OUTPUT_STRIP_TRAILING_WHITESPACE)
-      MESSAGE(STATUS "GDAL version is " ${GDAL_VERSION})
-      SET(GDAL_VERSION ${GDAL_VERSION} CACHE STRING "GDAL version" FORCE)
-      MARK_AS_ADVANCED(GDAL_VERSION)
-  ELSE (GDALCONFIG_EXECUTABLE)    
-      MESSAGE(STATUS "gdal-config not found")
-  ENDIF (GDALCONFIG_EXECUTABLE)
-  
-
-  # Find geotiff headers
-  FIND_PATH(GEOTIFF_INCLUDE_DIRS geotiff.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include/geotiff /usr/include/libgeotiff)
-  IF (NOT GEOTIFF_INCLUDE_DIRS)
-  MESSAGE(FATAL_ERROR
-           "Cannot find geotiff headers. Please set GEOTIFF_INCLUDE_DIRS.")
-  ENDIF (NOT GEOTIFF_INCLUDE_DIRS)
-#  INCLUDE_DIRECTORIES(${GEOTIFF_INCLUDE_DIRS})
-
-  # Find tiff headers
-  FIND_PATH(TIFF_INCLUDE_DIRS tiffio.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
-  IF (NOT TIFF_INCLUDE_DIRS)
-  MESSAGE(FATAL_ERROR
-           "Cannot find libtiff headers. Please set TIFF_INCLUDE_DIRS.")
-  ENDIF (NOT TIFF_INCLUDE_DIRS)
-#  INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIRS})
-
-  # Find jpeg headers
-  FIND_PATH(JPEG_INCLUDE_DIRS jpeglib.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
-  IF (NOT JPEG_INCLUDE_DIRS)
-  MESSAGE(FATAL_ERROR
-           "Cannot find jpeg headers. Please set JPEG_INCLUDE_DIRS.")
-  ENDIF (NOT JPEG_INCLUDE_DIRS)
-  INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIRS})
-
-  # Find ogr headers
-  FIND_PATH(OGR_INCLUDE_DIRS ogrsf_frmts.h  $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
-  IF (NOT OGR_INCLUDE_DIRS)
-  MESSAGE(FATAL_ERROR
-           "Cannot find ogr headers. Please set OGR_INCLUDE_DIRS.")
-  ENDIF (NOT OGR_INCLUDE_DIRS)
-  INCLUDE_DIRECTORIES(${OGR_INCLUDE_DIRS})
-
-  # Check if ${GDAL_LIBRARY} has tiff library
-  TRY_COMPILE(GDAL_HAS_TIFF
-  ${CMAKE_CURRENT_BINARY_DIR}/CMake
-  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasTiff.cxx
-  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${TIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
-  OUTPUT_VARIABLE OUTPUT)
-  IF(GDAL_HAS_TIFF)
-  MESSAGE(STATUS "Testing if GDAL has tiff    -- yes")
-  SET(TIFF_LIBRARY ${GDAL_LIBRARY})
-  ELSE(GDAL_HAS_TIFF)
-  MESSAGE(STATUS "Testing if GDAL has tiff    -- no")
-  FIND_LIBRARY(TIFF_LIBRARY tiff PATHS)
-  IF (NOT TIFF_LIBRARY)
-  MESSAGE(FATAL_ERROR
-           "Cannot find tiff library. Please set TIFF_LIBRARY.")
-  ENDIF (NOT TIFF_LIBRARY)
-  ENDIF(GDAL_HAS_TIFF)
-
-  # Check if ${GDAL_LIBRARY} has geotiff library
-  TRY_COMPILE(GDAL_HAS_GEOTIFF
-  ${CMAKE_CURRENT_BINARY_DIR}/CMake
-  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasGeoTiff.cxx
-  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GEOTIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
-  OUTPUT_VARIABLE OUTPUT)
-  IF(GDAL_HAS_GEOTIFF)
-  MESSAGE(STATUS "Testing if GDAL has geotiff -- yes")
-  SET(GEOTIFF_LIBRARY ${GDAL_LIBRARY})
-  ELSE(GDAL_HAS_GEOTIFF)
-  MESSAGE(STATUS "Testing if GDAL has geotiff -- no")
-  FIND_LIBRARY(GEOTIFF_LIBRARY geotiff PATHS)
-  IF (NOT GEOTIFF_LIBRARY)
-  MESSAGE(FATAL_ERROR
-           "Cannot find geotiff library. Please set GEOTIFF_LIBRARY.")
-  ENDIF (NOT GEOTIFF_LIBRARY)
-  ENDIF(GDAL_HAS_GEOTIFF)
-
-  # Check if ${GDAL_LIBRARY} has jpeg library
-  TRY_COMPILE(GDAL_HAS_JPEG
-  ${CMAKE_CURRENT_BINARY_DIR}/CMake
-  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasJpeg.cxx
-  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${JPEG_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
-  OUTPUT_VARIABLE OUTPUT)
-  IF(GDAL_HAS_JPEG)
-  MESSAGE(STATUS "Testing if GDAL has jpeg    -- yes")
-  SET(JPEG_LIBRARY ${GDAL_LIBRARY})
-  ELSE(GDAL_HAS_JPEG)
-  MESSAGE(STATUS "Testing if GDAL has jpeg    -- no")
-  FIND_LIBRARY(JPEG_LIBRARY jpeg PATHS)
-  IF (NOT JPEG_LIBRARY)
-  MESSAGE(FATAL_ERROR
-           "Cannot find jpeg library. Please set JPEG_LIBRARY.")
-  ENDIF (NOT JPEG_LIBRARY)
-  ENDIF(GDAL_HAS_JPEG)
-
-  # Check if ${GDAL_LIBRARY} has ogr library
-  TRY_COMPILE(GDAL_HAS_OGR
-  ${CMAKE_CURRENT_BINARY_DIR}/CMake
-  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasOGR.cxx
-  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${OGR_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
-  OUTPUT_VARIABLE OUTPUT)
-  IF(GDAL_HAS_OGR)
-  MESSAGE(STATUS "Testing if GDAL has OGR     -- yes")
-  SET(OGR_LIBRARY ${GDAL_LIBRARY})
-  ELSE(GDAL_HAS_OGR)
-  MESSAGE(STATUS "Testing if GDAL has OGR     -- no")
-  MESSAGE(FATAL_ERROR "OGR MESSAGE: ${OUTPUT}")
-  FIND_LIBRARY(OGR_LIBRARY ogr PATHS)
-  IF (NOT OGR_LIBRARY)
-  MESSAGE(FATAL_ERROR
-           "Cannot find ogr library. Please set OGR_LIBRARY.")
-  ENDIF (NOT OGR_LIBRARY)
-  ENDIF(GDAL_HAS_OGR)
-ELSE(OTB_USE_EXTERNAL_GDAL)
-ENDIF(OTB_USE_EXTERNAL_GDAL)
+# Advanced option to avoid recompiling utilities at each cmake reconfiguration
+OPTION(OTB_DISABLE_UTILITIES_COMPILATION "Disable utilities compilation (developpers only - use at you own risk)" OFF)
+MARK_AS_ADVANCED(OTB_DISABLE_UTILITIES_COMPILATION)
+IF(OTB_DISABLE_UTILITIES_COMPILATION)
+  MESSAGE("Warning: utilities compilation is disabled.")
+  LINK_DIRECTORIES("${OTB_BINARY_DIR}/bin")
+ENDIF(OTB_DISABLE_UTILITIES_COMPILATION)
 
 #-----------------------------------------------------------------------------
-# Option to generate Visu tools
-OPTION(OTB_USE_VISU_GUI "Generate Gui/Visu tools directory. If ON, find OpenGL and FLTK packages." ON)
-MARK_AS_ADVANCED(OTB_USE_VISU_GUI)
-
-SET(OTB_GLU_INCLUDE_PATH "")
-IF(OTB_USE_VISU_GUI)
-
-        #-------------------------------
-        # OpenGL Library
-        #-------------------------------
-        FIND_PACKAGE(OpenGL)
-
-        IF( NOT OPENGL_FOUND )
-                MESSAGE(FATAL_ERROR "Impossible to find OpenGL on your system.\nCannot build OTB Visu module without OpenGL library.\nInstall OpenGL on your system OR set OTB_USE_VISU_GUI to OFF to disable OTB Visu module generation !")
-	    ENDIF( NOT OPENGL_FOUND )
-        IF( NOT OPENGL_GLU_FOUND )
-                MESSAGE(FATAL_ERROR "Impossible to find GLU library on your system.\nCannot build OTB Visu module without GLU library.\nInstall GLU library on your system OR set OTB_USE_VISU_GUI to OFF to disable OTB Visu module generation !")
-        ENDIF( NOT OPENGL_GLU_FOUND )
-
-        IF(OPENGL_INCLUDE_DIR)
-                INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
-        ENDIF(OPENGL_INCLUDE_DIR)
-
-        #-------------------------------
-        # Display images using textures using video card acceleration
-        #-------------------------------
-        OPTION(OTB_GL_USE_ACCEL "Use video card acceleration." OFF)
-        MARK_AS_ADVANCED(OTB_GL_USE_ACCEL)
-
-        #-------------------------------
-        # FLTK Library
-        #-------------------------------
-        OPTION(OTB_USE_EXTERNAL_FLTK "Use an outside build of FLTK." OFF)
-
-        IF(OTB_USE_EXTERNAL_FLTK)
-          FIND_PACKAGE(FLTK)
-          IF(NOT FLTK_FOUND)
-            MESSAGE(FATAL_ERROR
-                  "Cannot build OTB project without FLTK. Please set FLTK_DIR or set OTB_USE_EXTERNAL_FLTK OFF to use INTERNAL FLTK.")
-          ENDIF(NOT FLTK_FOUND)
-        ELSE(OTB_USE_EXTERNAL_FLTK)
-          # Same Set as ITK
-          SET(FLTK_SOURCE_DIR ${OTB_SOURCE_DIR}/Utilities/FLTK)
-          SET(FLTK_BINARY_DIR ${OTB_BINARY_DIR}/Utilities/FLTK)
-          # Additionnal variables needed by OTB_VISU_GUI_LIBRARIES and FLTK_FLUID_EXECUTABLE
-          SET(FLTK_LIBRARIES "fltk_images;fltk;fltk_gl;fltk_forms")
-          SET(FLUID_COMMAND fluid)
-          # FLTK CMake needs a variable called JPEG_INCLUDE_DIR
-          SET(JPEG_INCLUDE_DIR ${JPEG_INCLUDE_DIRS})
-        ENDIF(OTB_USE_EXTERNAL_FLTK)
-
-        SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES} ")
-        SET(FLTK_FLUID_EXECUTABLE ${FLUID_COMMAND})
-ENDIF(OTB_USE_VISU_GUI)
-
-
-#-------------------------------
-# CURL Library
-#-------------------------------
-FIND_PACKAGE(CURL)
-IF(CURL_FOUND)
-  OPTION(OTB_USE_CURL "Use curl library." ON)
-ELSE(CURL_FOUND)
-  OPTION(OTB_USE_CURL "Use curl library." OFF)
-ENDIF(CURL_FOUND)
-
-MARK_AS_ADVANCED(OTB_USE_CURL)
-IF(OTB_USE_CURL)
-
-        FIND_PATH(CURL_INCLUDE_DIR curl/curl.h PATHS)
-        MARK_AS_ADVANCED(CURL_INCLUDE_DIR)
-        IF (NOT CURL_INCLUDE_DIR)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find CURL include directory. Please set CURL_INCLUDE_DIR or SET OTB_USE_CURL OFF.")
-        ENDIF (NOT CURL_INCLUDE_DIR)
-
-        FIND_LIBRARY(CURL_LIBRARY curl )
-        MARK_AS_ADVANCED(CURL_LIBRARY)
-        IF (NOT CURL_LIBRARY)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find CURL library. Please set CURL_LIBRARY or SET OTB_USE_CURL OFF.")
-        ENDIF (NOT CURL_LIBRARY)
-
-        # Add compiler option
-        ADD_DEFINITIONS(-DOTB_USE_CURL)
-
-        INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
-
-        # TODO add test to check if curl multi is available
-        TRY_COMPILE(OTB_CURL_MULTI_AVAILABLE
-                    ${CMAKE_CURRENT_BINARY_DIR}/CMake
-                    ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestCurlMulti.cxx
-                    CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${CURL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${CURL_LIBRARY}"
-                    OUTPUT_VARIABLE OUTPUT)
-        IF (OTB_CURL_MULTI_AVAILABLE)
-          ADD_DEFINITIONS(-DOTB_CURL_MULTI_AVAILABLE)
-        ENDIF (OTB_CURL_MULTI_AVAILABLE)
-ENDIF(OTB_USE_CURL)
-
-#-------------------------------
-# Mapnik Library
-#-------------------------------
-OPTION(OTB_USE_MAPNIK "Use mapnik library." OFF)
-MARK_AS_ADVANCED(OTB_USE_MAPNIK)
-IF(OTB_USE_MAPNIK)
-
-        FIND_PATH(MAPNIK_INCLUDE_DIR mapnik/map.hpp PATHS)
-        MARK_AS_ADVANCED(MAPNIK_INCLUDE_DIR)
-        IF (NOT MAPNIK_INCLUDE_DIR)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find MAPNIK include directory. Please set MAPNIK_INCLUDE_DIR or SET OTB_USE_MAPNIK OFF.")
-        ENDIF (NOT MAPNIK_INCLUDE_DIR)
-
-        FIND_PATH(FREETYPE2_INCLUDE_DIR freetype/freetype.h PATHS /usr/include/freetype2)
-        MARK_AS_ADVANCED(FREETYPE2_INCLUDE_DIR)
-        IF (NOT FREETYPE2_INCLUDE_DIR)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find FREETYPE2 include directory. Please set  or SET OTB_USE_MAPNIK OFF.")
-        ENDIF (NOT FREETYPE2_INCLUDE_DIR)
-
-        FIND_LIBRARY(MAPNIK_LIBRARY mapnik )
-        MARK_AS_ADVANCED(MAPNIK_LIBRARY)
-        IF (NOT MAPNIK_LIBRARY)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find MAPNIK library. Please set MAPNIK_LIBRARY or SET OTB_USE_MAPNIK OFF.")
-        ENDIF (NOT MAPNIK_LIBRARY)
-
-        # libicuuc is a unicode library mapnik relies on.
-        # since libicuuc version 1.42, we need to link against it when linking against mapnik
-        # otherwise we get undefined symbol error
-        FIND_LIBRARY(ICUUC_LIBRARY icuuc )
-        MARK_AS_ADVANCED(ICUUC_LIBRARY)
-        IF (NOT ICUUC_LIBRARY)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find ICUUC library, needed by MAPNIK. Please set ICUUC_LIBRARY or SET OTB_USE_MAPNIK OFF.")
-        ENDIF (NOT ICUUC_LIBRARY)
-
-        # Add compiler option
-        ADD_DEFINITIONS(-DOTB_USE_MAPNIK)
+# Output directories
+SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OTB_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for all ARCHIVE products (static libs, import libs)")
+SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OTB_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for all LIBRARY products (so, modules)")
+SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OTB_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for all RUNTIME products (executables, dlls)")
+
+# backward compatibility (TODO: remove these deprecated variables)
+SET(LIBRARY_OUTPUT_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+SET(OTB_LIBRARY_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+SET(OTB_EXECUTABLE_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+SET(CXX_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
-        INCLUDE_DIRECTORIES(${MAPNIK_INCLUDE_DIR})
-
-
-ENDIF(OTB_USE_MAPNIK)
-
-#-------------------------------
-# Pqxx Library
-#-------------------------------
-OPTION(OTB_USE_PQXX "Use pqxx library (EXPERIMENTAL)." OFF)
-MARK_AS_ADVANCED(OTB_USE_PQXX)
-IF(OTB_USE_PQXX)
-
-        FIND_PATH(PQXX_INCLUDE_DIR pqxx/pqxx PATHS)
-        MARK_AS_ADVANCED(PQXX_INCLUDE_DIR)
-        IF (NOT PQXX_INCLUDE_DIR)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find PQXX include directory. Please set PQXX_INCLUDE_DIR or SET OTB_USE_PQXX OFF.")
-        ENDIF (NOT PQXX_INCLUDE_DIR)
-
-
-        FIND_LIBRARY(PQXX_LIBRARY pqxx )
-        MARK_AS_ADVANCED(PQXX_LIBRARY)
-        IF (NOT PQXX_LIBRARY)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find PQXX library. Please set PQXX_LIBRARY or SET OTB_USE_PQXX OFF.")
-        ENDIF (NOT PQXX_LIBRARY)
-
-        FIND_LIBRARY(PQ_LIBRARY pq )
-        MARK_AS_ADVANCED(PQ_LIBRARY)
-        IF (NOT PQ_LIBRARY)
-                MESSAGE(FATAL_ERROR
-                        "Cannot find PQ library. Please set PQ_LIBRARY or SET OTB_USE_PQXX OFF.")
-        ENDIF (NOT PQ_LIBRARY)
-
-
-        # Add compiler option
-        ADD_DEFINITIONS(-DOTB_USE_PQXX)
-
-        INCLUDE_DIRECTORIES(${PQXX_INCLUDE_DIR})
-
-ENDIF(OTB_USE_PQXX)
-
-
-#-------------------------------
-# Boost Library
-#-------------------------------
-SET (Boost_MINOR_VERSION 0)
-
-OPTION(OTB_USE_EXTERNAL_BOOST "Use an outside build of Boost." OFF)
-
-IF(OTB_USE_EXTERNAL_BOOST)
-  FIND_PACKAGE(Boost)
-  IF(Boost_FOUND)
-    MESSAGE(STATUS "Found Boost version ${Boost_VERSION}")
-    IF( ${Boost_MINOR_VERSION} EQUAL 40)
-      MESSAGE(WARNING "Boost 1.40 not supported. Disabling OTB_USE_EXTERNAL_BOOST")
-      SET(OTB_USE_EXTERNAL_BOOST  OFF)
-    ENDIF(${Boost_MINOR_VERSION} EQUAL 40)
-    IF( ${Boost_MINOR_VERSION} LESS 35)
-      MESSAGE(WARNING "Boost >= 1.35 is required. Disabling OTB_USE_EXTERNAL_BOOST")
-      SET(OTB_USE_EXTERNAL_BOOST  OFF)
-    ENDIF(${Boost_MINOR_VERSION} LESS 35)
-  ELSE(Boost_FOUND)
-    MESSAGE(FATAL_ERROR
-                  "Cannot build OTB project without boost library.  Please set Boost directories or set OTB_USE_EXTERNAL_BOOST to OFF to use the INTERNAL Boost version")
-  ENDIF(Boost_FOUND)
-ENDIF(OTB_USE_EXTERNAL_BOOST)
-
-# Option for internal/external BOOST
-MARK_AS_ADVANCED(OTB_USE_EXTERNAL_BOOST)
-
-IF (OTB_USE_MAPNIK)
-  IF(NOT OTB_USE_EXTERNAL_BOOST)
-    MESSAGE("You need to set OTB_USE_EXTERNAL_BOOST to ON when using MAPNIK")
-  ENDIF(NOT OTB_USE_EXTERNAL_BOOST)
-ENDIF(OTB_USE_MAPNIK)
-
-IF(OTB_USE_EXTERNAL_BOOST)
-
-  TRY_COMPILE(BOOST_IS_COMPLETE
-  ${CMAKE_CURRENT_BINARY_DIR}/CMake
-  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/otbTestCompileBoost.cxx
-  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${Boost_INCLUDE_DIR}"
-  OUTPUT_VARIABLE OUTPUT)
-  IF(BOOST_IS_COMPLETE)
-    MESSAGE(STATUS "Testing external Boost library    -- yes")
-  ELSE(BOOST_IS_COMPLETE)
-    MESSAGE(STATUS "Testing external Boost library    -- no")
-    MESSAGE(STATUS "Force the OTB_USE_EXTERNAL_BOOST value to OFF.")
-    SET(OTB_USE_EXTERNAL_BOOST OFF CACHE BOOL  "Use an outside build of Boost." FORCE )
-  ENDIF(BOOST_IS_COMPLETE)
-ENDIF(OTB_USE_EXTERNAL_BOOST)
-
-
-
-#Experimental
-OPTION(OTB_USE_GETTEXT "Get Text Library." ON)
-
-IF(OTB_USE_GETTEXT)
-FIND_PACKAGE(Gettext)
-IF(GETTEXT_FOUND)
-  FIND_LIBRARY(GETTEXT_LIBRARY gettextlib DOC "GetText library")
-  IF(APPLE OR WIN32)
-    FIND_LIBRARY(GETTEXT_INTL_LIBRARY intl DOC "GetText intl library")
-  ENDIF(APPLE OR WIN32)
-
-  IF(GETTEXT_LIBRARY)
-      SET(OTB_I18N 1)
-      MESSAGE(STATUS
-              "Gettext found, configuring internationalization")
-      SET(OTB_LANG $ENV{LANG} CACHE STRING "OTB internationalization (Experimental)")#might want to get the Locale from the system here
-      IF(NOT OTB_LANG)
-        SET(OTB_LANG "en_EN.UTF-8" CACHE STRING "OTB internationalization (Experimental)" FORCE)
-      ENDIF(NOT OTB_LANG)
-      SET(OTB_LANG_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/I18n)
-      ADD_SUBDIRECTORY(I18n)
-      FIND_PATH(GETTEXT_INCLUDE_DIR
-        libintl.h
-        DOC "Path to gettext include directory (where libintl.h can be found)")
-      MARK_AS_ADVANCED(GETTEXT_INCLUDE_DIR)
-    
-      IF(GETTEXT_INCLUDE_DIR)
-        INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
-      ENDIF(GETTEXT_INCLUDE_DIR)
-  ENDIF(GETTEXT_LIBRARY)
-
-ELSE(GETTEXT_FOUND)
-  SET(OTB_I18N 0)
-  MESSAGE(STATUS
-              "Gettext not found, internationalization will not be available")
-ENDIF(GETTEXT_FOUND)
-ENDIF(OTB_USE_GETTEXT)
-
-#-------------------------------
-# End connections with external libraries
-#-------------------------------
+#-----------------------------------------------------------------------------
+# External libraries
+INCLUDE(ImportLibLAS)
+INCLUDE(ImportExpat)
+INCLUDE(ImportITK)
+INCLUDE(ImportJPEG2000)
+INCLUDE(ImportGdal)
+INCLUDE(ImportFLTK) # depends on ImportGdal
+INCLUDE(ImportCurl)
+INCLUDE(ImportPqxx)
+INCLUDE(ImportBoost)
+INCLUDE(ImportMapnik) # depends on ImportBoost
+INCLUDE(ImportGetText)
+INCLUDE(ImportOpenThreads)
 
 #-----------------------------------------------------------------------------
 # Installation vars.
@@ -805,123 +191,16 @@ STRING(REGEX REPLACE "^/" "" OTB_INSTALL_DOXYGEN_DIR_CM24 "${OTB_INSTALL_DOXYGEN
 STRING(REGEX REPLACE "^/" "" OTB_INSTALL_TCL_DIR_CM24 "${OTB_INSTALL_TCL_DIR}")
 STRING(REGEX REPLACE "^/" "" OTB_INSTALL_JAVA_DIR_CM24 "${OTB_INSTALL_JAVA_DIR}")
 
-# Make sure the user does not try to install on top of the build tree.
-IF(WIN32 OR APPLE OR UNIX)
-  STRING(TOLOWER "${CMAKE_INSTALL_PREFIX}" _PREFIX)
-  STRING(TOLOWER "${OTB_BINARY_DIR}" _BUILD)
-ELSE(WIN32 OR APPLE OR UNIX)
-  SET(_PREFIX "${CMAKE_INSTALL_PREFIX}")
-  SET(_BUILD "${OTB_BINARY_DIR}")
-ENDIF(WIN32 OR APPLE OR UNIX)
-IF("${_PREFIX}" STREQUAL "${_BUILD}")
-  MESSAGE(FATAL_ERROR
-    "The current CMAKE_INSTALL_PREFIX points at the build tree:\n"
-    "  ${CMAKE_INSTALL_PREFIX}\n"
-    "This is not supported."
-    )
-ENDIF("${_PREFIX}" STREQUAL "${_BUILD}")
-
-
-# The fluid-generated fltk sources have many warnings.  This macro
-# will disable warnings for the generated files on some compilers.
-MACRO(OTB_DISABLE_FLTK_GENERATED_WARNINGS files)
-  IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.6)
-    IF(CMAKE_COMPILER_IS_GNUCXX)
-      FOREACH(f ${files})
-        STRING(REGEX REPLACE "\\.fl$" ".cxx" SRC "${f}")
-        STRING(REGEX REPLACE ".*/([^/]*)$" "\\1" SRC "${SRC}")
-        SET_SOURCE_FILES_PROPERTIES(${SRC} PROPERTIES COMPILE_FLAGS -w)
-      ENDFOREACH(f)
-    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
-  ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.6)
-ENDMACRO(OTB_DISABLE_FLTK_GENERATED_WARNINGS)
-
-# Macro for adding resources to GUI application on the Mac
-#
-IF(APPLE AND NOT FLTK_USE_X)
-    FIND_PROGRAM(ITK_APPLE_RESOURCE Rez /Developer/Tools)
-    FIND_FILE(ITK_FLTK_RESOURCE mac.r ${FLTK_DIR}/include/FL)
-    IF(NOT ITK_FLTK_RESOURCE)
-      MESSAGE("Fltk resources not found, GUI application will not respond to mouse events")
-    ENDIF(NOT ITK_FLTK_RESOURCE)
-
-    MACRO(ADD_GUI_EXECUTABLE name sources)
-      ADD_EXECUTABLE(${name} ${sources})
-      INSTALL_TARGETS(/bin ${name})
-      SET(EXEC_PATH ${EXECUTABLE_OUTPUT_PATH})
-      IF(NOT EXEC_PATH)
-        SET(EXEC_PATH ${CMAKE_CURRENT_BINARY_DIR})
-      ENDIF(NOT EXEC_PATH)
-        IF(ITK_APPLE_RESOURCE)
-          ADD_CUSTOM_COMMAND(SOURCE ${name}
-                             COMMAND ${ITK_APPLE_RESOURCE}
-                             ARGS -t APPL ${ITK_FLTK_RESOURCE} -o
-                             ${EXEC_PATH}/${name}
-                             TARGET ${name})
-        ENDIF(ITK_APPLE_RESOURCE)
-    ENDMACRO(ADD_GUI_EXECUTABLE)
-ELSE(APPLE AND NOT FLTK_USE_X)
-  MACRO(ADD_GUI_EXECUTABLE name sources)
-    ADD_EXECUTABLE(${name} ${sources})
-    INSTALL_TARGETS(/bin ${name})
-  ENDMACRO(ADD_GUI_EXECUTABLE)
-ENDIF(APPLE AND NOT FLTK_USE_X)
-
+INCLUDE(PreventInstallOnBuildTree)
 
 INCLUDE_DIRECTORIES (
   ${OTB_BINARY_DIR}
   ${OTB_SOURCE_DIR}
-)
-
-INCLUDE_DIRECTORIES( ${OTB_INCLUDE_DIRS} )
-
-
-#-----------------------------------------------------------------------------
-# Test for some required system information.
-INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
-INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)
-
-#-----------------------------------------------------------------------------
-# Configure Dart testing support.  This should be done before any
-# MESSAGE(FATAL_ERROR ...) commands are invoked.
-INCLUDE(${CMAKE_ROOT}/Modules/Dart.cmake)
-MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
-ENABLE_TESTING()
-IF(BUILD_TESTING)
-  SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
-  MARK_AS_ADVANCED(BUILDNAME)
-ENDIF(BUILD_TESTING)
-
-
-
-INCLUDE_DIRECTORIES( ${OTB_LIBRARY_PATH} )
-
-IF(NOT OTB_NO_LIBRARY_VERSION)
-   # This setting of SOVERSION assumes that any API change
-   # will increment either the minor or major version number of OTB.
-   SET(OTB_LIBRARY_PROPERTIES
-       VERSION   "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH}"
-       SOVERSION "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
-ENDIF(NOT OTB_NO_LIBRARY_VERSION)
-
+  ${OTB_INCLUDE_DIRS}
+  ${OTB_LIBRARY_PATH} )
 
 #-----------------------------------------------------------------------------
-# Option for display all developpment message !!!
-OPTION(OTB_SHOW_ALL_MSG_DEBUG "OTB developers : Show all messages (debug, dev, etc...) use only for otb developers." OFF)
-MARK_AS_ADVANCED(OTB_SHOW_ALL_MSG_DEBUG)
-# IF( OTB_SHOW_ALL_MSG_DEBUG )
-#  ADD_DEFINITIONS(-DOTB_SHOW_ALL_MSG_DEBUG)
-# ENDIF( OTB_SHOW_ALL_MSG_DEBUG )
-
-OPTION(OTB_COMPILE_WITH_FULL_WARNING "OTB developers : Compilation with FULL warning (use only for otb developers)." OFF)
-MARK_AS_ADVANCED(OTB_COMPILE_WITH_FULL_WARNING)
-IF(OTB_COMPILE_WITH_FULL_WARNING)
-  IF(CMAKE_COMPILER_IS_GNUCXX)
-    SET(OTB_FULL_WARNING_LIST_PARAMETERS "-Wall -Wunused  -Wunused-function  -Wunused-label  -Wunused-parameter -Wunused-value -Wunused-variable -Wuninitialized -Wsign-compare -Wparentheses -Wunknown-pragmas -Wswitch" CACHE STRING "List of compilation parameters.")
-    MARK_AS_ADVANCED(OTB_FULL_WARNING_LIST_PARAMETERS)
-  ENDIF(CMAKE_COMPILER_IS_GNUCXX)
-
-ENDIF(OTB_COMPILE_WITH_FULL_WARNING)
+# Option for display all developpment message
 
 OPTION(OTB_CPP_CHECK_SOURCE_FILE "OTB developers : Checking cpp source file (use only for otb developers)." OFF)
 MARK_AS_ADVANCED(OTB_CPP_CHECK_SOURCE_FILE)
@@ -936,8 +215,6 @@ MACRO(OTB_ADD_EXECUTABLE name sources libraries)
   ADD_EXECUTABLE(${name} ${sources})
   TARGET_LINK_LIBRARIES(${name}  ${libraries})
   IF(OTB_CPP_CHECK_SOURCE_FILE)
-#  SET_TARGET_PROPERTIES(otbBasicFiltersTests1  PROPERTIES "OTBBasicFilters")
-#  ADD_DEPENDENCIES(otbBasicFiltersTests1  OTBBasicFilters)
     FOREACH( file ${sources})
       ADD_CUSTOM_COMMAND(   TARGET ${name}
                             PRE_BUILD
@@ -951,79 +228,6 @@ MACRO(OTB_ADD_EXECUTABLE name sources libraries)
 ENDMACRO(OTB_ADD_EXECUTABLE)
 
 
-#-----------------------------------------------------------------------------
-# Advanced option to avoid recompiling utilities at each cmake reconfiguration
-OPTION(OTB_DISABLE_UTILITIES_COMPILATION "Disable utilities compilation (developpers only - use at you own risk)" OFF)
-MARK_AS_ADVANCED(OTB_DISABLE_UTILITIES_COMPILATION)
-
-IF(OTB_DISABLE_UTILITIES_COMPILATION)
-MESSAGE("Warning: utilities compilation is disabled.")
-LINK_DIRECTORIES("${OTB_BINARY_DIR}/bin")
-ENDIF(OTB_DISABLE_UTILITIES_COMPILATION)
-
-
-#-----------------------------------------------------------------------------
-# Option to define streaming activation in applications
-# Use by otbConfigure.h.in
-# Note: 8*4000*4000 = 128000000 (double 4000x4000 image)
-SET(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING 128000000 CACHE STRING "Image size to activate using streaming for applications.")
-MARK_AS_ADVANCED(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING)
-SET(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING 128000000 CACHE STRING "Max size buffer for streaming.")
-MARK_AS_ADVANCED(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING)
-
-
-
-#-----------------------------------------------------------------------------
-# Option for generate Patented examples  !!!
-OPTION(OTB_USE_PATENTED "Build patented examples. ITK must be generated whith patented option (ITK_USE_PATENTED = ON)." OFF)
-MARK_AS_ADVANCED(OTB_USE_PATENTED)
-
-IF(OTB_USE_VISU_GUI)
-    SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES};${FLTK_PLATFORM_DEPENDENT_LIBS}")
-        IF(APPLE)
-            SET(OTB_VISU_GUI_LIBRARIES "${OTB_VISU_GUI_LIBRARIES};-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
-        ENDIF(APPLE)
-ELSE(OTB_USE_VISU_GUI)
-        SET(OTB_VISU_GUI_LIBRARIES "")
-ENDIF(OTB_USE_VISU_GUI)
-
-
-#-----------------------------------------------------------------------------
-# List of alls basics OTB libraries used for any applications
-# Use OTB_IO_UTILITIES_DEPENDENT_LIBRARIES to LINK IO libraries into your executable
-# Use OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES to LINK Utilities Algo libraries into your executable
-# Use OTB_ALLS_UTILITIES_DEPENDENT_LIBRARIES to LINK Utilities Algo libraries into your executable
-# => Create OTB_IO_UTILITIES_DEPENDENT_LIBRARIES
-# # #
-# # # SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${GDAL_LIBRARY};dxf;tinyXML;otbliblas;otbossim;otbossimplugins" )
-# # #
-# # # IF(NOT OTB_USE_EXTERNAL_OPENTHREADS)
-# # #         SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES  "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};${OPENTHREADS_LIBRARY}")
-# # # ENDIF(NOT OTB_USE_EXTERNAL_OPENTHREADS)
-# # #
-# # # # Add EXPAT library
-# # # IF( OTB_USE_EXTERNAL_EXPAT )
-# # #         SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES  "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};expat")
-# # # ELSE( OTB_USE_EXTERNAL_EXPAT  )
-# # #         SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES  "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};otbexpat")
-# # # ENDIF( OTB_USE_EXTERNAL_EXPAT )
-# # #
-# # # # Add Open Jpeg library
-# # # IF( OTB_COMPILE_JPEG2000 )
-# # #      SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};otbopenjpeg")
-# # # ENDIF( OTB_COMPILE_JPEG2000 )
-# # #
-# # # # => Create OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES
-# # # SET(OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES "otb6S;otbgalib;InsightJournal;otbsvm")
-# # #
-# # #
-# # # # => Create OTB_ALLS_UTILITIES_DEPENDENT_LIBRARIES
-# # # SET(OTB_ALLS_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES} ${OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES}")
-# # #
-
-#-----------------------------------------------------------------------------
-OPTION(BUILD_EXAMPLES "Build the Examples directory." OFF)
-
 
 #-----------------------------------------------------------------------------
 # The entire OTB tree should use the same include path
@@ -1042,51 +246,21 @@ INCLUDE_DIRECTORIES(
 
 #-----------------------------------------------------------------------------
 # Dispatch the build into the proper subdirectories.
-
-#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)
-ENDIF (BUILD_EXAMPLES)
-
 IF (BUILD_TESTING)
   ADD_SUBDIRECTORY(Testing)
 ENDIF (BUILD_TESTING)
 
-#-----------------------------------------------------------------------------
-# => Comment for OTB 2.6.0: simplification : copy ITK values
-# OTB requires special compiler flags on some platforms.
-SET(OTB_REQUIRED_C_FLAGS "${ITK_REQUIRED_C_FLAGS}")
-SET(OTB_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS}")
-SET(OTB_REQUIRED_LINK_FLAGS "${ITK_REQUIRED_LINK_FLAGS}")
+IF (BUILD_EXAMPLES)
+  ADD_SUBDIRECTORY(Examples)
+ENDIF (BUILD_EXAMPLES)
 
 IF(MINGW)
   LINK_LIBRARIES(gdi32)
 ENDIF(MINGW)
 
-#-----------------------------------------------------------------------------
-# Test for an Objective-C++ compiler.
-SET(OTB_OBJCXX_COMPILER_WORKS 0)
-IF(APPLE)
-  TRY_COMPILE(OTB_OBJCXX_COMPILER_WORKS
-              ${OTB_BINARY_DIR}/CMakeTmp
-              ${OTB_SOURCE_DIR}/CMake/otbTestObjCxxCompiler.mm
-              OUTPUT_VARIABLE OTB_OBJCXX_TRY_COMPILE_OUTPUT)
-  IF( OTB_OBJCXX_COMPILER_WORKS )
-    FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
-        "Determining if the Objective-C compiler works passed with "
-        "the following output:\n${OTB_OBJCXX_TRY_COMPILE_OUTPUT}\n\n")
-  ELSE( OTB_OBJCXX_COMPILER_WORKS )
-    FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
-      "Determining if the Objective-C compiler works failed with "
-      "the following output:\n${OTB_OBJCXX_TRY_COMPILE_OUTPUT}\n\n")
-  ENDIF( OTB_OBJCXX_COMPILER_WORKS )
-ENDIF(APPLE)
-
-
 INCLUDE(CheckTypeSize)
 
 CHECK_TYPE_SIZE("long long" OTB_SIZEOF_LONG_LONG)
@@ -1108,25 +282,11 @@ ENDIF(OTB_DATA_USE_LARGEINPUT)
 
 
 #-----------------------------------------------------------------------------
-# Configure files with settings for use by the build.
+# Configure files with settings for use by the build
+# This must be done after the definition of all options
 CONFIGURE_FILE(${OTB_SOURCE_DIR}/otbConfigure.h.in
                ${OTB_BINARY_DIR}/otbConfigure.h)
 
-#-----------------------------------------------------------------------------
-# 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}
-#)
-
 #-----------------------------------------------------------------------------
 # Uninstall cmake use to uninstall OTB.
 #    CONFIGURE_FILE(
@@ -1144,22 +304,9 @@ CONFIGURE_FILE(${OTB_SOURCE_DIR}/otbConfigure.h.in
 CONFIGURE_FILE(${OTB_SOURCE_DIR}/UseOTB.cmake.in
                ${OTB_BINARY_DIR}/UseOTB.cmake COPYONLY IMMEDIATE)
 
-
 # Save the compiler settings so another project can import them.
 INCLUDE(${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake)
 CMAKE_EXPORT_BUILD_SETTINGS(${OTB_BINARY_DIR}/OTBBuildSettings.cmake)
-#INSTALL_FILES(/lib/otb .cmake OTBBuildSettings)
-
-IF(NOT OTB_INSTALL_NO_DEVELOPMENT)
-  INSTALL(FILES
-    ${OTB_BINARY_DIR}/OTBBuildSettings.cmake
-    ${OTB_BINARY_DIR}/OTBLibraryDepends.cmake
-    ${OTB_BINARY_DIR}/UseOTB.cmake
-    ${OTB_SOURCE_DIR}/CMake/FindOpenThreads.cmake
-    DESTINATION ${OTB_INSTALL_PACKAGE_DIR_CM24}
-    COMPONENT Development
-    )
-ENDIF(NOT OTB_INSTALL_NO_DEVELOPMENT)
 
 # Save library dependencies.
 EXPORT_LIBRARY_DEPENDENCIES(${OTB_BINARY_DIR}/OTBLibraryDepends.cmake)
@@ -1168,90 +315,35 @@ EXPORT_LIBRARY_DEPENDENCIES(${OTB_BINARY_DIR}/OTBLibraryDepends.cmake)
 INCLUDE (${OTB_SOURCE_DIR}/otbGenerateOTBConfig.cmake)
 
 IF(NOT OTB_INSTALL_NO_DEVELOPMENT)
+  INSTALL(FILES
+    ${OTB_BINARY_DIR}/OTBBuildSettings.cmake
+    ${OTB_BINARY_DIR}/OTBLibraryDepends.cmake
+    ${OTB_BINARY_DIR}/UseOTB.cmake
+    ${OTB_SOURCE_DIR}/CMake/FindOpenThreads.cmake
+    DESTINATION ${OTB_INSTALL_PACKAGE_DIR_CM24}
+    COMPONENT Development)
+    
   INSTALL(FILES ${OTB_BINARY_DIR}/otbConfigure.h
     DESTINATION ${OTB_INSTALL_INCLUDE_DIR_CM24}
     COMPONENT Development)
 ENDIF(NOT OTB_INSTALL_NO_DEVELOPMENT)
 
-
-#INSTALL_FILES(/include/otb .h otbConfigure)
-#INSTALL_FILES(/lib/otb .cmake UseOTB OTBLibraryDepends OTBConfig )
+#-----------------------------------------------------------------------------
+# => Comment for OTB 2.6.0: simplification : copy ITK values
+# OTB requires special compiler flags on some platforms.
+SET(OTB_REQUIRED_C_FLAGS "${ITK_REQUIRED_C_FLAGS}")
+SET(OTB_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS}")
+SET(OTB_REQUIRED_LINK_FLAGS "${ITK_REQUIRED_LINK_FLAGS}")
 
 #-----------------------------------------------------------------------------
 # Add compiler flags OTB needs to work on this platform.  This must be
 # done AFTER the call to CMAKE_EXPORT_BUILD_SETTINGS.
-
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OTB_REQUIRED_C_FLAGS}")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OTB_REQUIRED_CXX_FLAGS}")
 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}")
 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}")
 SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}")
 
-#-----------------------------------------------------------------------------
-# Set up CPack support, to be able to distribute OTB binary packages. It will
-# be particulary useful to distributed prebuilt OTB.
-#
-
-OPTION(OTB_USE_CPACK "Generate installer using CPack" OFF)
-MARK_AS_ADVANCED(OTB_USE_CPACK)
-
-IF(OTB_USE_CPACK)
-
-    INCLUDE(InstallRequiredSystemLibraries)
-    
-    SET(CPACK_PACKAGE_NAME "OTB" CACHE STRING "Package name")
-    MARK_AS_ADVANCED(CPACK_PACKAGE_NAME)
-    
-    SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Orfeo Toolbox")
-    MARK_AS_ADVANCED(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
-    
-    SET(CPACK_PACKAGE_VERSION  "${OTB_VERSION_STRING}")
-    SET(CPACK_PACKAGE_VERSION_MAJOR "${OTB_VERSION_MAJOR}")
-    SET(CPACK_PACKAGE_VERSION_MINOR "${OTB_VERSION_MINOR}")
-    SET(CPACK_PACKAGE_VERSION_PATCH "${OTB_VERSION_PATCH}")
-    
-    SET(CPACK_PACKAGE_CONTACT "contact@orfeo-toolbox.org" CACHE STRING  "Orfeo toolbox contact email")
-    
-    SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Description.txt")
-    
-    #Debian specific
-    SET(DEBIAN_PACKAGE_MAINTAINER  "debian@orfeo-toolbox.org" CACHE STRING  "Debian package maintainer email")
-    SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libgdal1-1.5.0 (>= 1.5.1-0), libfltk1.1 (>= 1.1.7-3), libcurl3 (>=7.15.5-1etch1), libfftw3-3 (>=3.1.2-3.1)" CACHE STRING "Debian package dependance" )
-    SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" CACHE STRING "arch")
-    MARK_AS_ADVANCED(CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
-    SET(CPACK_DEBIAN_PACKAGE_NAME "libotb" CACHE STRING "Debian package name")
-    
-    SET(CPACK_PACKAGE_INSTALL_DIRECTORY "OrfeoToolbox-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
-    
-    SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright/OTBCopyright.txt")
-    
-    FILE(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
-    FILE(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_DEBIAN_PACKAGE_DESCRIPTION)
-    
-    IF(WIN32 AND NOT UNIX AND NOT CYGWIN)
-    #Find gdal dll files, localized in the GDAL_LIBRARY directory
-    GET_FILENAME_COMPONENT(GDAL_LIB_DIR "${GDAL_LIBRARY}" PATH )
-    SET(GDAL_LIB_DIR "${GDAL_LIB_DIR}/" )
-    INSTALL(DIRECTORY ${GDAL_LIB_DIR}
-            DESTINATION                 bin
-            FILES_MATCHING  PATTERN     "*.dll" )
-    INSTALL(DIRECTORY ${GDAL_LIB_DIR}
-            DESTINATION                 lib
-            FILES_MATCHING  PATTERN     "*.lib" )
-    ENDIF(WIN32 AND NOT UNIX AND NOT CYGWIN)
-    
-    INCLUDE(CPack)
-
-ENDIF(OTB_USE_CPACK)
-
-FILE(GLOB otbconfigfileCreation_SRCS "${OTB_SOURCE_DIR}/CMake/GenerateConfigProperties.cpp")
-SET(otbconfigfile_DEFAULT "${OTB_BINARY_DIR}/otb.conf")
-
-ADD_EXECUTABLE(GenerateConfigProperties ${otbconfigfileCreation_SRCS})
+INCLUDE(OTBCPack)
+INCLUDE(GenerateConfigProperties)
 
-ADD_CUSTOM_COMMAND(
-          TARGET GenerateConfigProperties
-          POST_BUILD
-          COMMAND GenerateConfigProperties
-          ARGS "${otbconfigfile_DEFAULT}" "${OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING}" "${OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING}"
-          COMMENT "Generating ${otbconfigfile_DEFAULT}" )
diff --git a/Code/IO/otbGDALImageIO.cxx b/Code/IO/otbGDALImageIO.cxx
index c7af76a06e5a9f824f515e8b99d8d3b2d17c87e0..62f31d56e764796e961478764bbcf45cfd67cffb 100644
--- a/Code/IO/otbGDALImageIO.cxx
+++ b/Code/IO/otbGDALImageIO.cxx
@@ -27,8 +27,10 @@
 #include "otbMacro.h"
 #include "otbSystem.h"
 #include "otbImage.h"
+#include "itkArray.h"
 
 #include "itkMetaDataObject.h"
+#include "otbMetaDataKey.h"
 
 #include "itkExceptionObject.h"
 #include "itkMacro.h"
@@ -38,6 +40,121 @@
 namespace otb
 {
 
+// only two states : the Pointer is Null or GetDataSet() returns a valid dataset
+class GDALDatasetWrapper : public itk::LightObject
+{
+  friend class GDALDriverManagerWrapper;
+
+public:
+  typedef GDALDatasetWrapper      Self;
+  typedef itk::LightObject        Superclass;
+  typedef itk::SmartPointer<Self> Pointer;
+
+  /** Method for creation through the object factory. */
+  itkNewMacro(Self);
+
+  /** Run-time type information (and related methods). */
+  itkTypeMacro(GDALImageIO, itk::LightObject);
+
+  /** Easy access to the internal GDALDataset object.
+   *  Don't close it, it will be automatic */
+  GDALDataset* GetDataSet()
+    {
+    return m_Dataset;
+    }
+
+protected :
+  GDALDatasetWrapper()
+   : m_Dataset(NULL)
+  {
+  }
+
+  ~GDALDatasetWrapper()
+  {
+    if (m_Dataset)
+      {
+      GDALClose(m_Dataset);
+      }
+  }
+
+private:
+  GDALDataset* m_Dataset;
+};
+
+
+// Wraps the GdalDriverManager so that GDALAllRegister is called automatically
+class GDALDriverManagerWrapper
+{
+public:
+  // GetInstance returns a reference to a GDALDriverManagerWrapper
+  // This is the only entry point to interact with this class
+  static GDALDriverManagerWrapper& GetInstance()
+  {
+
+    // Declare a static method variable of type GDALDriverManagerWrapper
+    // so that it is constructed and initialized only on the first call
+    // to GetInstance(), and so try to avoid static initialization order problems
+
+    static GDALDriverManagerWrapper theUniqueInstance;
+    return theUniqueInstance;
+  }
+
+  // Open the file for reading and returns a smart dataset pointer
+  GDALDatasetWrapper::Pointer Open( std::string filename )
+  {
+    GDALDatasetWrapper::Pointer datasetWrapper;
+    GDALDatasetH dataset = GDALOpen(filename.c_str(), GA_ReadOnly);
+    if (dataset != NULL)
+      {
+      datasetWrapper = GDALDatasetWrapper::New();
+      datasetWrapper->m_Dataset = static_cast<GDALDataset*>(dataset);
+      }
+    return datasetWrapper;
+  }
+
+  // Open the new  file for writing and returns a smart dataset pointer
+  GDALDatasetWrapper::Pointer Create( std::string driverShortName, std::string filename,
+                                      int nXSize, int nYSize, int nBands,
+                                      GDALDataType eType, char ** papszOptions )
+  {
+    GDALDatasetWrapper::Pointer datasetWrapper;
+
+    GDALDriver*  driver = GetDriverByName( driverShortName );
+    if(driver != NULL)
+      {
+      GDALDataset* dataset = driver->Create(filename.c_str(),
+                                            nXSize, nYSize,
+                                            nBands, eType,
+                                            papszOptions );
+
+      if (dataset != NULL)
+        {
+        datasetWrapper = GDALDatasetWrapper::New();
+        datasetWrapper->m_Dataset = dataset;
+        }
+      }
+    return datasetWrapper;
+  }
+
+
+  GDALDriver* GetDriverByName( std::string driverShortName )
+  {
+    return GetGDALDriverManager()->GetDriverByName(driverShortName.c_str());
+  }
+
+private :
+  // private constructor so that this class is allocated only inside GetInstance
+  GDALDriverManagerWrapper()
+  {
+    GDALAllRegister();
+  }
+
+  ~GDALDriverManagerWrapper()
+  {
+    GDALDestroyDriverManager();
+  }
+};
+
 GDALImageIO::GDALImageIO()
 {
   // By default set number of dimensions to two.
@@ -60,34 +177,18 @@ GDALImageIO::GDALImageIO()
 
   m_IsIndexed   = false;
   m_currentfile = NULL;
-  m_poBands     = NULL;
-  m_hDriver     = NULL;
-  m_poDataset   = NULL;
+  //m_poBands     = NULL;
+  //m_hDriver     = NULL;
+  //m_poDataset   = NULL;
 
   m_NbBands = 0;
   m_FlagWriteImageInformation = true;
 
-//  GDALAllRegister();
+  m_CanStreamWrite = false;
 }
 
 GDALImageIO::~GDALImageIO()
 {
-//THOMAS
-//  if( m_hDriver != NULL ) GDALClose( m_hDriver ); //Ne pas le faire  sinon SegFault !!!!
-//         if( m_poBands != NULL ) delete [] m_poBands;
-//   if( m_poDataset != NULL ) delete m_poDataset;
-
-  if (m_poDataset != NULL)
-    {
-
-    GDALClose(m_poDataset);
-    m_poDataset = NULL;
-    }
-  if (m_poBands != NULL)
-    {
-    delete[] m_poBands;
-    }
-  GDALDestroyDriverManager();
 }
 
 // Tell only if the file can be read with GDAL.
@@ -99,38 +200,8 @@ bool GDALImageIO::CanReadFile(const char* file)
     itkDebugMacro(<< "No filename specified.");
     return false;
     }
-
-  std::string lFileNameGdal;
-  lFileNameGdal = std::string(file);
-
-  // Init GDAL parameters
-  GDALAllRegister();
-
-  // Open file with GDAL
-  m_poDataset = static_cast<GDALDataset *>(GDALOpen(lFileNameGdal.c_str(), GA_ReadOnly));
-
-  if (m_poDataset == NULL)
-    {
-    fprintf(stderr,
-            "GDALOpen failed - %d\n%s\n",
-            CPLGetLastErrorNo(), CPLGetLastErrorMsg());
-
-    GDALDestroyDriverManager();
-    CPLDumpSharedList(NULL);
-    itkDebugMacro(<< "No dataset ");
-    otbMsgDevMacro(<< "Not CanReadFile GDAL");
-    return false;
-    }
-  else
-    {
-    GDALClose(m_poDataset);
-    m_poDataset = NULL;
-    GDALDestroyDriverManager();
-    CPLDumpSharedList(NULL);
-
-    otbMsgDevMacro(<< "CanReadFile GDAL");
-    return true;
-    }
+  m_Dataset = GDALDriverManagerWrapper::GetInstance().Open(file);
+  return m_Dataset.IsNotNull();
 }
 
 // Used to print information about this object
@@ -156,41 +227,37 @@ void GDALImageIO::Read(void* buffer)
     return;
     }
 
-  int lNbLines   = this->GetIORegion().GetSize()[1];
-  int lNbColumns = this->GetIORegion().GetSize()[0];
+  int lNbLines     = this->GetIORegion().GetSize()[1];
+  int lNbColumns   = this->GetIORegion().GetSize()[0];
   int lFirstLine   = this->GetIORegion().GetIndex()[1]; // [1... ]
   int lFirstColumn = this->GetIORegion().GetIndex()[0]; // [1... ]
 
   std::streamoff lNbPixels = (static_cast<std::streamoff>(lNbColumns)) * (static_cast<std::streamoff>(lNbLines));
   std::streamoff lBufferSize = static_cast<std::streamoff>(m_NbOctetPixel) * lNbPixels;
 
-  unsigned char* value = new unsigned char[lBufferSize];
-  if (value == NULL)
-    {
-    itkExceptionMacro(<< "Memory allocation error");
-    return;
-    }
+  itk::Array<unsigned char> value(lBufferSize);
 
   CPLErr         lCrGdal;
   std::streamoff cpt(0);
+  GDALDataset* dataset = m_Dataset->GetDataSet();
 
   if (GDALDataTypeIsComplex(m_PxType))
     {
-    lCrGdal = m_poBands[0]->RasterIO(GF_Read,
-                                     lFirstColumn,
-                                     lFirstLine,
-                                     lNbColumns,
-                                     lNbLines,
-                                     value,
-                                     lNbColumns,
-                                     lNbLines,
-                                     m_PxType,
-                                     0,
-                                     0);
+    lCrGdal = dataset->GetRasterBand(1)->RasterIO(GF_Read,
+                                                 lFirstColumn,
+                                                 lFirstLine,
+                                                 lNbColumns,
+                                                 lNbLines,
+                                                 value.data_block(),
+                                                 lNbColumns,
+                                                 lNbLines,
+                                                 m_PxType,
+                                                 0,
+                                                 0);
 
     if (lCrGdal == CE_Failure)
       {
-      itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName.c_str() << ".");
+      itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName );
       }
     cpt = 0;
     for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_NbOctetPixel))
@@ -203,12 +270,12 @@ void GDALImageIO::Read(void* buffer)
     {
     step = step * static_cast<std::streamoff>(m_NbOctetPixel);
 
-    lCrGdal = m_poBands[0]->RasterIO(GF_Read,
+    lCrGdal = dataset->GetRasterBand(1)->RasterIO(GF_Read,
                                      lFirstColumn,
                                      lFirstLine,
                                      lNbColumns,
                                      lNbLines,
-                                     value,
+                                     value.data_block(),
                                      lNbColumns,
                                      lNbLines,
                                      m_PxType,
@@ -220,17 +287,17 @@ void GDALImageIO::Read(void* buffer)
       }
     // Recopie dans le buffer
     cpt = 0;
+    GDALColorTable* colorTable = dataset->GetRasterBand(1)->GetColorTable();
     for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_NbOctetPixel))
       {
       GDALColorEntry color;
-      m_poBands[0]->GetColorTable()->GetColorEntryAsRGB(value[i], &color);
+      colorTable->GetColorEntryAsRGB(value[i], &color);
       p[cpt] = color.c1;
       p[cpt + 1] = color.c2;
       p[cpt + 2] = color.c3;
       p[cpt + 3] = color.c4;
       cpt += step;
       }
-
     }
   else
     {
@@ -239,17 +306,17 @@ void GDALImageIO::Read(void* buffer)
 
     for (unsigned int nbComponents = 0; nbComponents < this->GetNumberOfComponents(); ++nbComponents)
       {
-      lCrGdal = m_poBands[nbComponents]->RasterIO(GF_Read,
-                                                  lFirstColumn,
-                                                  lFirstLine,
-                                                  lNbColumns,
-                                                  lNbLines,
-                                                  value,
-                                                  lNbColumns,
-                                                  lNbLines,
-                                                  m_PxType,
-                                                  0,
-                                                  0);
+      lCrGdal = dataset->GetRasterBand(nbComponents+1)->RasterIO(GF_Read,
+                                                                lFirstColumn,
+                                                                lFirstLine,
+                                                                lNbColumns,
+                                                                lNbLines,
+                                                                value.data_block(),
+                                                                lNbColumns,
+                                                                lNbLines,
+                                                                m_PxType,
+                                                                0,
+                                                                0);
       if (lCrGdal == CE_Failure)
         {
         itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName.c_str() << ".");
@@ -263,9 +330,6 @@ void GDALImageIO::Read(void* buffer)
         }
       }
     }
-
-  delete[] value;
-  value = NULL;
 }
 
 void GDALImageIO::ReadImageInformation()
@@ -276,53 +340,21 @@ void GDALImageIO::ReadImageInformation()
 
 void GDALImageIO::InternalReadImageInformation()
 {
-  int i;
-
-  if (m_FileName.empty() == true)
-    {
-    itkExceptionMacro(<< "GDAl read : empty image file name file.");
-    }
-
-  std::string lFileNameGdal = m_FileName;
-
-  // Init GDAL parameters
-  GDALAllRegister();
-
-  // Get Dataset
-  if (m_poDataset != NULL)
-    {
-//       delete m_poDataset;
-    GDALClose(m_poDataset);
-    m_poDataset = NULL;
-    }
-  m_poDataset = static_cast<GDALDataset *>(GDALOpen(lFileNameGdal.c_str(), GA_ReadOnly));
+  GDALDataset* dataset = m_Dataset->GetDataSet();
   otbMsgDevMacro(<< "  GCPCount (original): " << m_poDataset->GetGCPCount());
 
-  if (m_poDataset == NULL)
-    {
-    itkExceptionMacro(<< "Gdal dataset is null.");
-    return;
-    }
-
-//  else
-//  {
-// Get image dimensions
-  m_width = m_poDataset->GetRasterXSize();
-  m_height = m_poDataset->GetRasterYSize();
-
-  if ((m_width == 0) || (m_height == 0))
+  // Get image dimensions
+  if ( dataset->GetRasterXSize() == 0 || dataset->GetRasterYSize() == 0 )
     {
     itkExceptionMacro(<< "Dimension is undefined.");
     }
-  else
-    {
-    // Set image dimensions into IO
-    m_Dimensions[0] = m_width;
-    m_Dimensions[1] = m_height;
-    }
+
+  // Set image dimensions into IO
+  m_Dimensions[0] = dataset->GetRasterXSize();
+  m_Dimensions[1] = dataset->GetRasterYSize();
 
   // Get Number of Bands
-  m_NbBands = m_poDataset->GetRasterCount();
+  m_NbBands = dataset->GetRasterCount();
   if (m_NbBands == 0)
     {
 //FIXME this happen in the case of a hdf file with SUBDATASETS
@@ -361,20 +393,10 @@ void GDALImageIO::InternalReadImageInformation()
   // Automatically set the Type to Binary for GDAL data
   this->SetFileTypeToBinary();
 
-  // Get all the Bands
-  m_poBands = new GDALRasterBand *[m_NbBands];
-  if (m_poBands == NULL)
-    {
-    itkExceptionMacro(<< "Memory allocation error for the 'rasterBands'");
-    return;
-    }
-  for (i = 0; i < m_NbBands; ++i)
-    m_poBands[i] = m_poDataset->GetRasterBand(i + 1);
-
   // Get Data Type
-  // Consider only the data type given by the first band!!!!!
+  // Consider only the data type given by the first band
   // Maybe be could changed (to check)
-  m_PxType = m_poBands[0]->GetRasterDataType();
+  m_PxType = dataset->GetRasterBand(1)->GetRasterDataType();
 
   // Following the data type given by GDAL we set it for ImageIO
   // BE CAREFUL !!!! At this time the complex data type are regarded
@@ -474,7 +496,6 @@ void GDALImageIO::InternalReadImageInformation()
       this->SetPixelType(VECTOR);
       }
     }
-  // }
 
   /*----------------------------------------------------------------------*/
   /*-------------------------- METADATA ----------------------------------*/
@@ -493,31 +514,31 @@ void GDALImageIO::InternalReadImageInformation()
   if (m_NumberOfDimensions == 3) m_Spacing[2] = 1;
 
   char** papszMetadata;
-  papszMetadata =  m_poDataset->GetMetadata(NULL);
+  papszMetadata =  dataset->GetMetadata(NULL);
 
   /* -------------------------------------------------------------------- */
   /*      Report general info.                                            */
   /* -------------------------------------------------------------------- */
   GDALDriverH hDriver;
 
-  hDriver = m_poDataset->GetDriver();
+  hDriver = dataset->GetDriver();
 
   std::string driverShortName =  static_cast<std::string>(GDALGetDriverShortName(hDriver));
-  std::string driverLongName =  static_cast<std::string>(GDALGetDriverLongName(hDriver));
+  std::string driverLongName  =  static_cast<std::string>(GDALGetDriverLongName(hDriver));
 
   itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::DriverShortNameKey, driverShortName);
-  itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::DriverLongNameKey, driverLongName);
+  itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::DriverLongNameKey,  driverLongName);
 
   /* -------------------------------------------------------------------- */
   /* Get the projection coordinate system of the image : ProjectionRef  */
   /* -------------------------------------------------------------------- */
 
-  if (m_poDataset->GetProjectionRef() != NULL && !std::string(m_poDataset->GetProjectionRef()).empty())
+  if (dataset->GetProjectionRef() != NULL && !std::string(dataset->GetProjectionRef()).empty())
     {
     OGRSpatialReferenceH pSR = OSRNewSpatialReference(NULL);
 
     const char *         pszProjection = NULL;
-    pszProjection =  m_poDataset->GetProjectionRef();
+    pszProjection =  dataset->GetProjectionRef();
 
     if (OSRImportFromWkt(pSR,(char **) (&pszProjection)) == OGRERR_NONE)
       {
@@ -531,7 +552,7 @@ void GDALImageIO::InternalReadImageInformation()
       }
     else
       itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey,
-                                            static_cast<std::string>(m_poDataset->GetProjectionRef()));
+                                            static_cast<std::string>(dataset->GetProjectionRef()));
 
     if (pSR != NULL)
       {
@@ -545,10 +566,10 @@ void GDALImageIO::InternalReadImageInformation()
   /* -------------------------------------------------------------------- */
 
   unsigned int gcpCount = 0;
-  gcpCount = m_poDataset->GetGCPCount();
+  gcpCount = dataset->GetGCPCount();
   if (gcpCount > 0)
     {
-    std::string gcpProjectionKey = static_cast<std::string>(m_poDataset->GetGCPProjection());
+    std::string gcpProjectionKey = static_cast<std::string>(dataset->GetGCPProjection());
     itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::GCPProjectionKey, gcpProjectionKey);
 
     if (gcpProjectionKey.empty())
@@ -565,7 +586,7 @@ void GDALImageIO::InternalReadImageInformation()
       {
 
       const GDAL_GCP *psGCP;
-      psGCP = m_poDataset->GetGCPs() + cpt;
+      psGCP = dataset->GetGCPs() + cpt;
 
       OTB_GCP pOtbGCP(psGCP);
 
@@ -585,14 +606,14 @@ void GDALImageIO::InternalReadImageInformation()
   /* -------------------------------------------------------------------- */
 
   double     adfGeoTransform[6];
-  VectorType VadfGeoTransform;
+  MetaDataKey::VectorType VadfGeoTransform;
 
-  if (m_poDataset->GetGeoTransform(adfGeoTransform) == CE_None)
+  if (dataset->GetGeoTransform(adfGeoTransform) == CE_None)
     {
     for (int cpt = 0; cpt < 6; cpt++)
       VadfGeoTransform.push_back(adfGeoTransform[cpt]);
 
-    itk::EncapsulateMetaData<VectorType>(dict, MetaDataKey::GeoTransformKey, VadfGeoTransform);
+    itk::EncapsulateMetaData<MetaDataKey::VectorType>(dict, MetaDataKey::GeoTransformKey, VadfGeoTransform);
 
     /// retrieve orgin and spacing from the geo transform
     m_Origin[0] = VadfGeoTransform[0];
@@ -618,7 +639,7 @@ void GDALImageIO::InternalReadImageInformation()
   /*      Report metadata.                                                */
   /* -------------------------------------------------------------------- */
 
-  papszMetadata = m_poDataset->GetMetadata(NULL);
+  papszMetadata = dataset->GetMetadata(NULL);
   if (CSLCount(papszMetadata) > 0)
     {
     std::string key;
@@ -638,7 +659,7 @@ void GDALImageIO::InternalReadImageInformation()
   /*      Report subdatasets.                                             */
   /* -------------------------------------------------------------------- */
 
-  papszMetadata = m_poDataset->GetMetadata("SUBDATASETS");
+  papszMetadata = dataset->GetMetadata("SUBDATASETS");
   if (CSLCount(papszMetadata) > 0)
     {
     std::string key;
@@ -659,37 +680,37 @@ void GDALImageIO::InternalReadImageInformation()
   /* -------------------------------------------------------------------- */
 
   double     GeoX(0), GeoY(0);
-  VectorType VGeo;
+  MetaDataKey::VectorType VGeo;
 
   GDALInfoReportCorner("Upper Left", 0.0, 0.0, GeoX, GeoY);
   VGeo.push_back(GeoX);
   VGeo.push_back(GeoY);
 
-  itk::EncapsulateMetaData<VectorType>(dict, MetaDataKey::UpperLeftCornerKey, VGeo);
+  itk::EncapsulateMetaData<MetaDataKey::VectorType>(dict, MetaDataKey::UpperLeftCornerKey, VGeo);
 
   VGeo.clear();
 
-  GDALInfoReportCorner("Upper Right", m_width, 0.0, GeoX, GeoY);
+  GDALInfoReportCorner("Upper Right", m_Dimensions[0], 0.0, GeoX, GeoY);
   VGeo.push_back(GeoX);
   VGeo.push_back(GeoY);
 
-  itk::EncapsulateMetaData<VectorType>(dict, MetaDataKey::UpperRightCornerKey, VGeo);
+  itk::EncapsulateMetaData<MetaDataKey::VectorType>(dict, MetaDataKey::UpperRightCornerKey, VGeo);
 
   VGeo.clear();
 
-  GDALInfoReportCorner("Lower Left", 0.0, m_height, GeoX, GeoY);
+  GDALInfoReportCorner("Lower Left", 0.0, m_Dimensions[1], GeoX, GeoY);
   VGeo.push_back(GeoX);
   VGeo.push_back(GeoY);
 
-  itk::EncapsulateMetaData<VectorType>(dict, MetaDataKey::LowerLeftCornerKey, VGeo);
+  itk::EncapsulateMetaData<MetaDataKey::VectorType>(dict, MetaDataKey::LowerLeftCornerKey, VGeo);
 
   VGeo.clear();
 
-  GDALInfoReportCorner("Lower Right", m_width, m_height, GeoX, GeoY);
+  GDALInfoReportCorner("Lower Right", m_Dimensions[0], m_Dimensions[1], GeoX, GeoY);
   VGeo.push_back(GeoX);
   VGeo.push_back(GeoY);
 
-  itk::EncapsulateMetaData<VectorType>(dict, MetaDataKey::LowerRightCornerKey, VGeo);
+  itk::EncapsulateMetaData<MetaDataKey::VectorType>(dict, MetaDataKey::LowerRightCornerKey, VGeo);
 
   VGeo.clear();
 
@@ -697,11 +718,11 @@ void GDALImageIO::InternalReadImageInformation()
   /* Color Table                                                          */
   /* -------------------------------------------------------------------- */
 
-  for (int iBand = 0; iBand < m_poDataset->GetRasterCount(); iBand++)
+  for (int iBand = 0; iBand < dataset->GetRasterCount(); iBand++)
     {
     GDALColorTableH hTable;
     GDALRasterBandH hBand;
-    hBand = GDALGetRasterBand(m_poDataset, iBand + 1);
+    hBand = GDALGetRasterBand(dataset, iBand + 1);
     if ((GDALGetRasterColorInterpretation(hBand) == GCI_PaletteIndex)
         && (hTable = GDALGetRasterColorTable(hBand)) != NULL)
       {
@@ -718,7 +739,7 @@ void GDALImageIO::InternalReadImageInformation()
       for (int i = 0; i < GDALGetColorEntryCount(hTable); ++i)
         {
         GDALColorEntry sEntry;
-        VectorType     VColorEntry;
+        MetaDataKey::VectorType VColorEntry;
 
         GDALGetColorEntryAsRGB(hTable, i, &sEntry);
 
@@ -727,7 +748,7 @@ void GDALImageIO::InternalReadImageInformation()
         VColorEntry.push_back(sEntry.c3);
         VColorEntry.push_back(sEntry.c4);
 
-        itk::EncapsulateMetaData<VectorType>(dict, MetaDataKey::ColorEntryAsRGBKey, VColorEntry);
+        itk::EncapsulateMetaData<MetaDataKey::VectorType>(dict, MetaDataKey::ColorEntryAsRGBKey, VColorEntry);
 
         }
       }
@@ -742,30 +763,58 @@ void GDALImageIO::InternalReadImageInformation()
 
 bool GDALImageIO::CanWriteFile(const char* name)
 {
-  // First check the extension
+  // First check the filename
   if (name == NULL)
     {
     itkDebugMacro(<< "No filename specified.");
     return false;
     }
 
-  // Recuperation du type a partir du nom de fichier
-  std::string extGDAL = TypeConversion(name);
-  if (extGDAL == "NOT-FOUND")
+  // Get the GDAL format ID from the name
+  std::string gdalDriverShortName = FilenameToGdalDriverShortName(name);
+  if (gdalDriverShortName == "NOT-FOUND")
     {
     return false;
     }
 
+  // Check the driver for support of Create or at least CreateCopy
+  GDALDriver* driver = GDALDriverManagerWrapper::GetInstance().GetDriverByName(gdalDriverShortName);
+  if ( GDALGetMetadataItem( driver, GDAL_DCAP_CREATE, NULL ) == NULL
+       && GDALGetMetadataItem( driver, GDAL_DCAP_CREATECOPY, NULL ) == NULL )
+    {
+    itkDebugMacro(<< "The driver " << GDALGetDriverShortName(driver) << " does not support writing");
+    return false;
+    }
   return true;
+}
+
+bool GDALImageIO::CanStreamWrite()
+{
+  // Get the GDAL format ID from the name
+  std::string gdalDriverShortName = FilenameToGdalDriverShortName(m_FileName);
+  GDALDriver* driver = GDALDriverManagerWrapper::GetInstance().GetDriverByName(gdalDriverShortName);
+  if (driver == NULL)
+    {
+    itkDebugMacro(<< "Unable to instantiate driver " << gdalDriverShortName);
+    m_CanStreamWrite = false;
+    }
 
+  if ( GDALGetMetadataItem( driver, GDAL_DCAP_CREATE, NULL ) != NULL )
+    {
+    m_CanStreamWrite = true;
+    }
+  else
+    {
+    m_CanStreamWrite = false;
+    }
+  return m_CanStreamWrite;
 }
 
-/** TODO : Methode Write non implementee */
 void GDALImageIO::Write(const void* buffer)
 {
   if (m_FlagWriteImageInformation == true)
     {
-    this->InternalWriteImageInformation();
+    this->InternalWriteImageInformation(buffer);
     m_FlagWriteImageInformation = false;
     }
 
@@ -776,12 +825,12 @@ void GDALImageIO::Write(const void* buffer)
     return;
     }
 
-  unsigned int lNbLines   = this->GetIORegion().GetSize()[1];
+  unsigned int lNbLines = this->GetIORegion().GetSize()[1];
   unsigned int lNbColumns = this->GetIORegion().GetSize()[0];
-  int          lFirstLine   = this->GetIORegion().GetIndex()[1]; // [1... ]
-  int          lFirstColumn = this->GetIORegion().GetIndex()[0]; // [1... ]
+  int lFirstLine = this->GetIORegion().GetIndex()[1]; // [1... ]
+  int lFirstColumn = this->GetIORegion().GetIndex()[0]; // [1... ]
 
-  // Particular case: checking that the writen region is the same size
+  // Particular case: checking that the written region is the same size
   // of the entire image
   // starting at offset 0 (when no streaming)
   if ((lNbLines == m_Dimensions[1]) && (lNbColumns == m_Dimensions[0]))
@@ -790,71 +839,71 @@ void GDALImageIO::Write(const void* buffer)
     lFirstColumn = 0;
     }
 
-  std::streamoff lNbPixels = static_cast<std::streamoff>(lNbColumns) * static_cast<std::streamoff>(lNbLines);
-  std::streamoff lBufferSize = static_cast<std::streamoff>(m_NbOctetPixel) * lNbPixels;
+  std::streamoff lNbPixels = static_cast<std::streamoff> (lNbColumns) * static_cast<std::streamoff> (lNbLines);
+  std::streamoff lBufferSize = static_cast<std::streamoff> (m_NbOctetPixel) * lNbPixels;
   otbMsgDevMacro(<< " BufferSize allocated : " << lBufferSize);
 
-  unsigned char* value = new unsigned char[lBufferSize];
-  if (value == NULL)
+  itk::Array<unsigned char> value(lBufferSize);
+
+  if (m_CanStreamWrite)
     {
-    itkExceptionMacro(<< "Memory allocation error");
-    return;
-    }
+    // Update Step
+    std::streamoff step = static_cast<std::streamoff> (m_NbBands);
+    step = step * static_cast<std::streamoff> (m_NbOctetPixel);
 
-  // Mise a jour du step
-  std::streamoff step = static_cast<std::streamoff>(m_NbBands);
-  step = step * static_cast<std::streamoff>(m_NbOctetPixel);
+    CPLErr lCrGdal;
 
-  CPLErr lCrGdal;
+    std::streamoff cpt(0);
+    for (int nbComponents = 0; nbComponents < m_NbBands; ++nbComponents)
+      {
+      cpt = static_cast<std::streamoff> (nbComponents) * static_cast<std::streamoff> (m_NbOctetPixel);
 
-  std::streamoff cpt(0);
-  for (int nbComponents = 0; nbComponents < m_NbBands; ++nbComponents)
-    {
-    cpt = static_cast<std::streamoff>(nbComponents) * static_cast<std::streamoff>(m_NbOctetPixel);
+      for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff> (m_NbOctetPixel))
+        {
+        memcpy((void*) (&(value[i])), (const void*) (&(p[cpt])), (size_t) (m_NbOctetPixel));
+        cpt += step;
+        }
+      GDALRasterBand *poBand = m_Dataset->GetDataSet()->GetRasterBand(nbComponents+1);
 
-    for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_NbOctetPixel))
-      {
-      memcpy((void*) (&(value[i])), (const void*) (&(p[cpt])), (size_t) (m_NbOctetPixel));
-      cpt += step;
-      }
-    GDALRasterBand *poBand;
-    poBand =  m_poBands[nbComponents]; //m_poDataset->GetRasterBand(nbComponents+1);
-//          lCrGdal = poBand->RasterIO(GF_Write,lFirstColumn,lFirstLine,lNbColumns, lNbLines, value , lNbColumns, lNbLines, m_PxType,0, 0 );
-    lCrGdal = m_poBands[nbComponents]->RasterIO(GF_Write,
-                                                lFirstColumn,
-                                                lFirstLine,
-                                                lNbColumns,
-                                                lNbLines,
-                                                value,
-                                                lNbColumns,
-                                                lNbLines,
-                                                m_PxType,
-                                                0,
-                                                0);
-    if (lCrGdal == CE_Failure)
-      {
-      itkExceptionMacro(<< "Error while writing image (GDAL format) " << m_FileName.c_str() << ".");
+      lCrGdal = poBand->RasterIO(GF_Write, lFirstColumn, lFirstLine, lNbColumns, lNbLines, value.data_block(),
+                                 lNbColumns, lNbLines, m_PxType, 0, 0);
+      if (lCrGdal == CE_Failure)
+        {
+        itkExceptionMacro(<< "Error while writing image (GDAL format) " << m_FileName.c_str() << ".");
+        }
+
+      poBand->FlushCache();
       }
-    m_poBands[nbComponents]->FlushCache();
+    m_Dataset->GetDataSet()->FlushCache();
     }
+  else
+    {
+    // We only wrote data to the memory dataset
+    // Now write it to the real file with CreateCopy()
+    std::string gdalDriverShortName = FilenameToGdalDriverShortName(m_FileName);
+    std::string realFileName = GetGdalWriteImageFileName(gdalDriverShortName, m_FileName);
 
-  delete[] value;
-  value = NULL;
+    GDALDriver* driver = GDALDriverManagerWrapper::GetInstance().GetDriverByName(gdalDriverShortName);
+    if (driver == NULL)
+      {
+      itkExceptionMacro(<< "Unable to instantiate driver " << gdalDriverShortName << " to write " << m_FileName);
+      }
 
-  m_poDataset->FlushCache();
+    GDALDataset* hOutputDS = driver->CreateCopy( realFileName.c_str(), m_Dataset->GetDataSet(), FALSE,
+                                                 NULL, NULL, NULL );
+    GDALClose(hOutputDS);
+    }
 }
 
 /** TODO : Methode WriteImageInformation non implementee */
 void GDALImageIO::WriteImageInformation()
 {
-
 }
 
-void GDALImageIO::InternalWriteImageInformation()
+void GDALImageIO::InternalWriteImageInformation(const void* buffer)
 {
-
   char **     papszOptions = NULL;
-  std::string extGDAL;
+  std::string driverShortName;
   m_NbBands = this->GetNumberOfComponents();
 
   if ((m_Dimensions[0] == 0) && (m_Dimensions[1] == 0))
@@ -945,58 +994,52 @@ void GDALImageIO::InternalWriteImageInformation()
   // Automatically set the Type to Binary for GDAL data
   this->SetFileTypeToBinary();
 
-  GDALAllRegister();
-
-  extGDAL = TypeConversion(m_FileName);
-  if (extGDAL == "NOT-FOUND")
+  driverShortName = FilenameToGdalDriverShortName(m_FileName);
+  if (driverShortName == "NOT-FOUND")
     {
     itkExceptionMacro(
-      << "GDAL Writing failed : the image file name '" << m_FileName.c_str() << "' is not reconized by GDAL.");
+      << "GDAL Writing failed : the image file name '" << m_FileName.c_str() << "' is not recognized by GDAL.");
     }
 
-  m_hDriver = GetGDALDriverManager()->GetDriverByName(extGDAL.c_str());
-  if (m_hDriver == NULL)
+  if (m_CanStreamWrite)
     {
-    itkExceptionMacro(<< "GDAL Writing failed : Driver not reconized");
+    m_Dataset = GDALDriverManagerWrapper::GetInstance().Create(
+                     driverShortName,
+                     GetGdalWriteImageFileName(driverShortName, m_FileName),
+                     m_Dimensions[0],m_Dimensions[1],
+                     m_NbBands, m_PxType,
+                     papszOptions);
     }
-  std::string realFileName = GetGdalWriteImageFileName(extGDAL, m_FileName);
-
-  if (m_poDataset != NULL)
-    {
-    GDALClose(m_poDataset);
-    m_poDataset = NULL;
-    }
-  m_poDataset = m_hDriver->Create(
-    realFileName.c_str(), m_Dimensions[0], m_Dimensions[1], m_NbBands, m_PxType, papszOptions);
-  if (m_poDataset == NULL)
+  else
     {
-    itkExceptionMacro(
-      << "GDAL Writing failed : Impossible to create the image file name '" << realFileName.c_str() << "'.");
-    }
-
-  // Get all the Bands
-  m_poBands = new GDALRasterBand *[m_NbBands];
+    std::ostringstream stream;
+    stream << "MEM:::"
+           <<  "DATAPOINTER=" << buffer << ","
+           <<  "PIXELS=" << m_Dimensions[0] << ","
+           <<  "LINES=" << m_Dimensions[1] << ","
+           <<  "BANDS=" << m_NbBands << ","
+           <<  "DATATYPE=" << GDALGetDataTypeName(m_PxType) << ","
+           <<  "PIXELOFFSET=" << m_NbOctetPixel * m_NbBands << ","
+           <<  "LINEOFFSET=" << m_NbOctetPixel * m_NbBands * m_Dimensions[0] << ","
+           <<  "BANDOFFSET=" << m_NbOctetPixel;
 
-  if (m_poBands == NULL)
-    {
-    itkExceptionMacro(<< "Memory allocation error for 'rasterBands'");
+    m_Dataset = GDALDriverManagerWrapper::GetInstance().Open(stream.str());
     }
-  for (int i = 0; i < m_NbBands; ++i)
+
+  if (m_Dataset.IsNull())
     {
-    m_poBands[i] = m_poDataset->GetRasterBand(i + 1);
+    itkExceptionMacro(
+      << "GDAL Writing failed : Impossible to create the image file name '" << m_FileName << "'.");
     }
 
-  // JULIEN: ADDING SUPPORT FOR METADATA WRITING.
-
   /*----------------------------------------------------------------------*/
   /*-------------------------- METADATA ----------------------------------*/
   /*----------------------------------------------------------------------*/
 
   // Now initialize the itk dictionary
   itk::MetaDataDictionary& dict = this->GetMetaDataDictionary();
-  char**                   papszMetadata;
-  papszMetadata =  m_poDataset->GetMetadata(NULL);
   itk::OStringStream oss;
+  GDALDataset* dataset = m_Dataset->GetDataSet();
 
   /* -------------------------------------------------------------------- */
   /* Set the GCPs                                                          */
@@ -1032,7 +1075,7 @@ void GDALImageIO::InternalWriteImageInformation()
 
     std::string gcpProjectionRef;
     itk::ExposeMetaData<std::string>(dict, MetaDataKey::GCPProjectionKey, gcpProjectionRef);
-    m_poDataset->SetGCPs(gcpCount, gdalGcps, gcpProjectionRef.c_str());
+    dataset->SetGCPs(gcpCount, gdalGcps, gcpProjectionRef.c_str());
 
     delete[] gdalGcps;
     }
@@ -1045,14 +1088,14 @@ void GDALImageIO::InternalWriteImageInformation()
   itk::ExposeMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, projectionRef);
   if (!projectionRef.empty())
     {
-    m_poDataset->SetProjection(projectionRef.c_str());
+    dataset->SetProjection(projectionRef.c_str());
     }
 
   /* -------------------------------------------------------------------- */
   /*  Set the six coefficients of affine geoTtransform      */
   /* -------------------------------------------------------------------- */
 
-  double * geoTransform = new double[6];
+  itk::Array<double> geoTransform(6);
   /// Reporting origin and spacing
   geoTransform[0] = m_Origin[0];
   geoTransform[3] = m_Origin[1];
@@ -1062,8 +1105,7 @@ void GDALImageIO::InternalWriteImageInformation()
   // FIXME: Here component 1 and 4 should be replaced by the orientation parameters
   geoTransform[2] = 0.;
   geoTransform[4] = 0.;
-  m_poDataset->SetGeoTransform(geoTransform);
-  delete[] geoTransform;
+  dataset->SetGeoTransform(geoTransform.data_block());
 
   /* -------------------------------------------------------------------- */
   /*      Report metadata.                                                */
@@ -1082,43 +1124,48 @@ void GDALImageIO::InternalWriteImageInformation()
       std::string  tag = svalue.substr(0, equalityPos);
       std::string  value = svalue.substr(equalityPos + 1);
       otbMsgDevMacro(<< "Metadata: " << tag << "=" << value);
-      m_poDataset->SetMetadataItem(tag.c_str(), value.c_str(), NULL);
+      dataset->SetMetadataItem(tag.c_str(), value.c_str(), NULL);
       }
     }
   // END
 
 }
 
-std::string GDALImageIO::TypeConversion(std::string name)
+std::string GDALImageIO::FilenameToGdalDriverShortName(std::string name)
 {
   std::string extension;
-  std::string extGDAL;
-
-  //Recuperer extension du fichier image
-  extension = System::GetExtension(name);
-
-  if ((extension == "tif") || (extension == "tiff") || (extension == "TIF") || (extension == "TIFF")) extGDAL = "GTiff";
-  else if ((extension == "hdr") || (extension == "HDR")) extGDAL = "ENVI";
-  else if ((extension == "img") || (extension == "IMG")) extGDAL = "HFA";
-  else if (extension == "ntf") extGDAL = "NITF";
-//Pas PNG car BUG !!
-//  else if ((extension=="png")||(extension=="PNG"))
-//      extGDAL="PNG";
-//Pas JPEG car BUG !!
-//  else if ((extension=="jpg")||(extension=="JPG")||(extension=="jpeg")||(extension=="JPEG"))
-//      extGDAL="JPEG";
-  else if ((extension=="pix")||(extension=="PIX")) extGDAL="PCIDSK";
-  else extGDAL = "NOT-FOUND";
-  return extGDAL;
+  std::string gdalDriverShortName;
+
+  // Get extension in lowercase
+  extension = otb::System::SetToLower( System::GetExtension(name) );
+
+  if      ( extension == "tif" || extension == "tiff" )
+    gdalDriverShortName = "GTiff";
+  else if ( extension == "hdr" )
+    gdalDriverShortName = "ENVI";
+  else if ( extension == "img" )
+    gdalDriverShortName = "HFA";
+  else if ( extension == "ntf" )
+    gdalDriverShortName = "NITF";
+  else if ( extension == "png" )
+    gdalDriverShortName="PNG";
+  else if ( extension == "jpg" || extension=="jpeg" )
+    gdalDriverShortName="JPEG";
+  else if ( extension == "pix" )
+    gdalDriverShortName="PCIDSK";
+  else
+    gdalDriverShortName = "NOT-FOUND";
+
+  return gdalDriverShortName;
 }
 
-std::string GDALImageIO::GetGdalWriteImageFileName(std::string& extGDAL, std::string filename)
+std::string GDALImageIO::GetGdalWriteImageFileName(std::string& gdalDriverShortName, std::string filename)
 {
   std::string gdalFileName;
 
   gdalFileName = filename;
-  //Suppression de l'extension HDR
-  if (extGDAL == "ENVI")
+  // Suppress hdr extension for ENVI format
+  if (gdalDriverShortName == "ENVI")
     {
     gdalFileName = System::GetRootName(filename);
     }
@@ -1135,9 +1182,9 @@ bool GDALImageIO::GDALInfoReportCorner(const char * /*corner_name*/, double x, d
   /* -------------------------------------------------------------------- */
   /*      Transform the point into georeferenced coordinates.             */
   /* -------------------------------------------------------------------- */
-  if (m_poDataset->GetGeoTransform(adfGeoTransform) == CE_None)
+  if (m_Dataset->GetDataSet()->GetGeoTransform(adfGeoTransform) == CE_None)
     {
-    pszProjection = m_poDataset->GetProjectionRef();
+    pszProjection = m_Dataset->GetDataSet()->GetProjectionRef();
 
     GeoX = adfGeoTransform[0] + adfGeoTransform[1] * x
            + adfGeoTransform[2] * y;
diff --git a/Code/IO/otbGDALImageIO.h b/Code/IO/otbGDALImageIO.h
index 21ffca4ac8051e4e50b131fe87b1ee1c7bae9744..ceff6ea357b403d7d51105efdeea91a3ce5dc561 100644
--- a/Code/IO/otbGDALImageIO.h
+++ b/Code/IO/otbGDALImageIO.h
@@ -29,8 +29,6 @@
 /* ITK Libraries */
 #include "itkImageIOBase.h"
 
-#include "otbMetaDataKey.h"
-
 /* GDAL Libraries */
 #include "gdal.h"
 #include "gdal_priv.h"
@@ -41,6 +39,7 @@
 
 namespace otb
 {
+class GDALDatasetWrapper;
 
 /** \class GDALImageIO
  *
@@ -51,8 +50,7 @@ namespace otb
  * \ingroup IOFilters
  *
  */
-class ITK_EXPORT GDALImageIO : public itk::ImageIOBase,
-  public MetaDataKey
+class ITK_EXPORT GDALImageIO : public itk::ImageIOBase
 {
 public:
 
@@ -102,11 +100,7 @@ public:
   virtual bool CanWriteFile(const char*);
 
   /** Determine the file type. Returns true if the ImageIO can stream write the specified file */
-//THOMAS
-  virtual bool CanStreamWrite()
-  {
-    return true;
-  }
+  virtual bool CanStreamWrite();
 
   /** Writes the spacing and dimentions of the image.
    * Assumes SetFileName has been called with a valid file name. */
@@ -116,9 +110,6 @@ public:
    * that the IORegion has been set properly. */
   virtual void Write(const void* buffer);
 
-  // JULIEN: NOT USED, NOT IMPLEMENTED
-  //void SampleImage(void* buffer,int XBegin, int YBegin, int SizeXRead, int SizeYRead, int XSample, int YSample);
-
 protected:
   /** Constructor.*/
   GDALImageIO();
@@ -129,11 +120,7 @@ protected:
   /** Read all information on the image*/
   void InternalReadImageInformation();
   /** Write all information on the image*/
-  void InternalWriteImageInformation();
-  /** Dimension along Ox of the image*/
-  int m_width;
-  /** Dimension along Oy of the image*/
-  int m_height;
+  void InternalWriteImageInformation(const void* buffer);
   /** Number of bands of the image*/
   int m_NbBands;
   /** Buffer*/
@@ -150,14 +137,15 @@ private:
   void operator =(const Self&); //purposely not implemented
 
   /** Determine real file name to write the image */
-  std::string GetGdalWriteImageFileName(std::string& extGDAL, std::string filename);
+  std::string GetGdalWriteImageFileName(std::string& gdalDriverShortName, std::string filename);
+
+  std::string FilenameToGdalDriverShortName(std::string name);
 
-  std::string TypeConversion(std::string name);
 
   /** GDAL parameters. */
-  GDALDriver*      m_hDriver;
-  GDALDataset*     m_poDataset;
-  GDALRasterBand** m_poBands;
+  typedef itk::SmartPointer<GDALDatasetWrapper> GDALDatasetWrapperPointer;
+  GDALDatasetWrapperPointer m_Dataset;
+
   GDALDataType     m_PxType;
   /** Nombre d'octets par pixel */
   int m_NbOctetPixel;
@@ -166,6 +154,7 @@ private:
                             double& dfGeoX, double& dfGeoY);
 
   bool m_FlagWriteImageInformation;
+  bool m_CanStreamWrite;
 
 };
 
diff --git a/Code/IO/otbMSTARImageIO.cxx b/Code/IO/otbMSTARImageIO.cxx
index 037e25e81a198d5edde358710676471a6eacf37f..3b8ab06bef362c05ce4a55079528feedfc8574c4 100644
--- a/Code/IO/otbMSTARImageIO.cxx
+++ b/Code/IO/otbMSTARImageIO.cxx
@@ -34,7 +34,6 @@
 #define MSB_FIRST    1             /* Implies big-endian CPU...    */
 
 #include "itkExceptionObject.h"
-#include "itkJPEGImageIO.h"
 
 #include <iostream>
 #include <list>
diff --git a/Code/IO/otbTileMapImageIO.cxx b/Code/IO/otbTileMapImageIO.cxx
index a7eb7788985e260003dc9680f301f57a9b33485d..9ace32e355cc5dec1e0241b5ec03c5a590814260 100644
--- a/Code/IO/otbTileMapImageIO.cxx
+++ b/Code/IO/otbTileMapImageIO.cxx
@@ -32,8 +32,9 @@
 #include "otbMacro.h"
 #include "otbSystem.h"
 
-#include "itkPNGImageIO.h"
-#include "itkJPEGImageIO.h"
+//#include "itkPNGImageIO.h"
+//#include "itkJPEGImageIO.h"
+#include "otbGDALImageIO.h"
 
 #include "base/ossimFilename.h"
 
@@ -218,23 +219,8 @@ void TileMapImageIO::GenerateTileInfo(double x, double y, int numTileX, int numT
 bool TileMapImageIO::CanReadFromCache(std::string filename)
 {
   itk::ImageIOBase::Pointer imageIO;
-  //Open the file to fill the buffer
-  if (m_FileSuffix == "png")
-    {
-    imageIO = itk::PNGImageIO::New();
-    }
-  else if (m_FileSuffix == "jpg")
-    {
-    imageIO = itk::JPEGImageIO::New();
-    }
-  else
-    {
-    itkExceptionMacro(<< "TileMapImageIO : Bad addressing Style");
-    }
-  bool lCanRead(false);
-  lCanRead = imageIO->CanReadFile(filename.c_str());
-
-  return lCanRead;
+  imageIO = otb::GDALImageIO::New();
+  return imageIO->CanReadFile(filename.c_str());
 }
 
 /*
@@ -353,26 +339,21 @@ void TileMapImageIO::ReadTile(std::string filename, void * buffer)
 {
   otbMsgDevMacro(<< "Retrieving " << filename);
   unsigned char *           bufferCacheFault = NULL;
-  itk::ImageIOBase::Pointer imageIO;
 
-  if (m_FileSuffix == "png")
-    {
-    imageIO = itk::PNGImageIO::New();
-    }
-  else if (m_FileSuffix == "jpg")
-    {
-    imageIO = itk::JPEGImageIO::New();
-    }
-  else
-    {
-    itkExceptionMacro(<< "TileMapImageIO : Bad addressing Style");
-    }
-  bool lCanRead(false);
-  lCanRead = imageIO->CanReadFile(filename.c_str());
+  itk::ImageIOBase::Pointer imageIO;
+  imageIO = otb::GDALImageIO::New();
+  bool lCanRead = imageIO->CanReadFile(filename.c_str());
 
   if (lCanRead == true)
     {
     imageIO->SetFileName(filename.c_str());
+    imageIO->ReadImageInformation();
+    itk::ImageIORegion ioRegion(2);
+    ioRegion.SetIndex(0, 0);
+    ioRegion.SetIndex(1, 0);
+    ioRegion.SetSize(0, 256);
+    ioRegion.SetSize(1, 256);
+    imageIO->SetIORegion(ioRegion);
     imageIO->Read(buffer);
     }
   else
@@ -430,7 +411,7 @@ void TileMapImageIO::ReadImageInformation()
   m_Dimensions[0] = (1 << m_Depth) * 256;
   m_Dimensions[1] = (1 << m_Depth) * 256;
   otbMsgDevMacro(<< "Get Dimensions : x=" << m_Dimensions[0] << " & y=" << m_Dimensions[1]);
-  this->SetNumberOfComponents(3);
+  this->SetNumberOfComponents(4);
   this->SetNumberOfDimensions(2);
   this->SetFileTypeToBinary();
   SetComponentType(UCHAR);
@@ -646,26 +627,13 @@ void TileMapImageIO::InternalWrite(double x, double y, const void* buffer)
   BuildFileName(quad, filename);
 
   itk::ImageIOBase::Pointer imageIO;
-  //Open the file to write the buffer
-  if (m_FileSuffix == "png")
-    {
-    imageIO = itk::PNGImageIO::New();
-    }
-  else if (m_FileSuffix == "jpg")
-    {
-    imageIO = itk::JPEGImageIO::New();
-    }
-  else
-    {
-    itkExceptionMacro(<< "TileMapImageIO : Bad addressing Style");
-    }
+  imageIO = otb::GDALImageIO::New();
+  bool lCanWrite = imageIO->CanWriteFile(filename.str().c_str());
 
-  bool lCanWrite(false);
-  lCanWrite = imageIO->CanWriteFile(filename.str().c_str());
-  otbMsgDevMacro(<< filename.str());
 
-  if (lCanWrite == true)
+  if (lCanWrite)
     {
+    imageIO->CanStreamWrite();
     imageIO->SetNumberOfDimensions(2);
     imageIO->SetDimensions(0, 256);
     imageIO->SetDimensions(1, 256);
diff --git a/OTBConfig.cmake.in b/OTBConfig.cmake.in
index feda9d6bd410754db2c02b6a25857528d282ad1f..d92f8db4d0f7983bc9e37fea572bb34be71d3ca3 100644
--- a/OTBConfig.cmake.in
+++ b/OTBConfig.cmake.in
@@ -138,7 +138,7 @@ SET(OTB_USE_PATENTED "@OTB_USE_PATENTED@")
 
 #LibLAS support
 SET(OTB_USE_LIBLAS "@OTB_USE_LIBLAS@")
-SET(OTB_USE_EXTERNAL_LIBLAS "@OTB_USE_LIBLAS@")
+SET(OTB_USE_EXTERNAL_LIBLAS "@OTB_USE_EXTERNAL_LIBLAS@")
 
 #Mapnik support
 SET(OTB_USE_MAPNIK "@OTB_USE_MAPNIK@")
diff --git a/Utilities/ITK/CMakeLists.txt b/Utilities/ITK/CMakeLists.txt
index 12a93d641dc2f18f39853c47b125469d29330b7a..c1d5e4e612bf5d5ea753359d2c81971557f8dc74 100644
--- a/Utilities/ITK/CMakeLists.txt
+++ b/Utilities/ITK/CMakeLists.txt
@@ -481,9 +481,9 @@ ENDIF(ITK_USE_SYSTEM_VXL)
 
 
 # Provide options to use system versions of third-party libraries.
-ITK_THIRD_PARTY_OPTION(ZLIB zlib)
-ITK_THIRD_PARTY_OPTION(PNG  png)
-ITK_THIRD_PARTY_OPTION(TIFF tiff)
+#ITK_THIRD_PARTY_OPTION(ZLIB zlib)
+#ITK_THIRD_PARTY_OPTION(PNG  png)
+#ITK_THIRD_PARTY_OPTION(TIFF tiff)
 
 OPTION(ITK_USE_LIBXML2 "Use LIBXML2." OFF)
 MARK_AS_ADVANCED(ITK_USE_LIBXML2)
@@ -812,42 +812,42 @@ INCLUDE_DIRECTORIES(
 # if GDCM was build with VTK support, including it will bring the VTK
 # include paths as well, and the wrong DICOMParser will be picked.
 
-OPTION(ITK_USE_SYSTEM_GDCM "Use an outside build of GDCM." OFF)
-MARK_AS_ADVANCED(ITK_USE_SYSTEM_GDCM)
-IF(ITK_USE_SYSTEM_GDCM)
-  FIND_PACKAGE(GDCM)
-  IF(GDCM_FOUND)
-    INCLUDE(${GDCM_USE_FILE})
-    IF( "${GDCM_MAJOR_VERSION}" LESS 2.0 )
-      SET(ITK_GDCM_LIBRARIES gdcm)
-    ELSE( "${GDCM_MAJOR_VERSION}" LESS 2.0 )
-      IF(ITK_USE_SYSTEM_TIFF)
-        # Long story short. ITKIO is NOT linked to itkjpeg8 explicitely. itkjpeg8 dep is being
-        # pulled from linking to itktiff. However in case of ITK_SYSTEM_TIFF the FindTIFF module
-        # do not explicitely link to the system jpeg. One can check however that on most GNU/Linux system
-        # $ ldd /usr/lib/libtiff.so
-        #    linux-vdso.so.1 =>  (0x00007fff67fff000)
-        #    libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x00007f635f9f2000)
-        # As a side note, ITK_SYSTEM_TIFF is somewhat robust as itkjpeg8 dep can also be pulled from
-        # linking to the default gdcm libraries since they use the itkjpeg libraries.
-        # I do not know the correct fix:
-        # 1. Have FindTIFF link to jpeg8 (which would be the right thing to do for static system libtiff)
-        # 2. Have ITKIO explicitely link to itkjpeg8
-        # For the time being let's explicitely pull the dep to itkjpeg8 ourselves.
-        SET(ITK_GDCM_LIBRARIES gdcmMSFF itkjpeg8)
-      ELSE(ITK_USE_SYSTEM_TIFF)
-        SET(ITK_GDCM_LIBRARIES gdcmMSFF)
-      ENDIF(ITK_USE_SYSTEM_TIFF)
-    ENDIF( "${GDCM_MAJOR_VERSION}" LESS 2.0 )
-  ELSE(GDCM_FOUND)
-    MESSAGE(FATAL_ERROR "Must set GDCM_DIR for ITK_USE_SYSTEM_GDCM.")
-  ENDIF(GDCM_FOUND)
-ELSE(ITK_USE_SYSTEM_GDCM)
-  SET(ITK_GDCM_LIBRARIES itkgdcm)
-  SET(GDCM_INCLUDE_DIR
-    ${ITK_SOURCE_DIR}/Utilities/gdcm/src
-    )
-ENDIF(ITK_USE_SYSTEM_GDCM)
+#OPTION(ITK_USE_SYSTEM_GDCM "Use an outside build of GDCM." OFF)
+#MARK_AS_ADVANCED(ITK_USE_SYSTEM_GDCM)
+#IF(ITK_USE_SYSTEM_GDCM)
+#  FIND_PACKAGE(GDCM)
+#  IF(GDCM_FOUND)
+#    INCLUDE(${GDCM_USE_FILE})
+#    IF( "${GDCM_MAJOR_VERSION}" LESS 2.0 )
+#      SET(ITK_GDCM_LIBRARIES gdcm)
+#    ELSE( "${GDCM_MAJOR_VERSION}" LESS 2.0 )
+#      IF(ITK_USE_SYSTEM_TIFF)
+#        # Long story short. ITKIO is NOT linked to itkjpeg8 explicitely. itkjpeg8 dep is being
+#        # pulled from linking to itktiff. However in case of ITK_SYSTEM_TIFF the FindTIFF module
+#        # do not explicitely link to the system jpeg. One can check however that on most GNU/Linux system
+#        # $ ldd /usr/lib/libtiff.so
+#        #    linux-vdso.so.1 =>  (0x00007fff67fff000)
+#        #    libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x00007f635f9f2000)
+#        # As a side note, ITK_SYSTEM_TIFF is somewhat robust as itkjpeg8 dep can also be pulled from
+#        # linking to the default gdcm libraries since they use the itkjpeg libraries.
+#        # I do not know the correct fix:
+#        # 1. Have FindTIFF link to jpeg8 (which would be the right thing to do for static system libtiff)
+#        # 2. Have ITKIO explicitely link to itkjpeg8
+#        # For the time being let's explicitely pull the dep to itkjpeg8 ourselves.
+#        SET(ITK_GDCM_LIBRARIES gdcmMSFF itkjpeg8)
+#      ELSE(ITK_USE_SYSTEM_TIFF)
+#        SET(ITK_GDCM_LIBRARIES gdcmMSFF)
+#      ENDIF(ITK_USE_SYSTEM_TIFF)
+#    ENDIF( "${GDCM_MAJOR_VERSION}" LESS 2.0 )
+#  ELSE(GDCM_FOUND)
+#    MESSAGE(FATAL_ERROR "Must set GDCM_DIR for ITK_USE_SYSTEM_GDCM.")
+#  ENDIF(GDCM_FOUND)
+#ELSE(ITK_USE_SYSTEM_GDCM)
+#  SET(ITK_GDCM_LIBRARIES itkgdcm)
+#  SET(GDCM_INCLUDE_DIR
+#    ${ITK_SOURCE_DIR}/Utilities/gdcm/src
+#    )
+#ENDIF(ITK_USE_SYSTEM_GDCM)
 
 #-----------------------------------------------------------------------------
 # Help other projects use ITK.
diff --git a/Utilities/ITK/Code/IO/CMakeLists.txt b/Utilities/ITK/Code/IO/CMakeLists.txt
index 51a63f788c992faceaae386faf82fe916eb5c4ae..01f1ab4e04ec159e7099f19b0ca4dd3bc91bfa2b 100644
--- a/Utilities/ITK/Code/IO/CMakeLists.txt
+++ b/Utilities/ITK/Code/IO/CMakeLists.txt
@@ -8,12 +8,12 @@ SET(ITKIO_SRCS
   itkBioRadImageIOFactory.cxx
 #  itkBMPImageIO.cxx
 #  itkBMPImageIOFactory.cxx
-  itkBrains2HeaderBase.cxx
-  itkBrains2HeaderFactory.cxx
-  itkBrains2IPLHeaderInfo.cxx
-  itkBrains2MaskHeaderInfo.cxx
-  itkBrains2MaskImageIO.cxx
-  itkBrains2MaskImageIOFactory.cxx
+#  itkBrains2HeaderBase.cxx
+#  itkBrains2HeaderFactory.cxx
+#  itkBrains2IPLHeaderInfo.cxx
+#  itkBrains2MaskHeaderInfo.cxx
+#  itkBrains2MaskImageIO.cxx
+#  itkBrains2MaskImageIOFactory.cxx
 #  itkDICOMImageIO2.cxx
 #  itkDICOMImageIO2Factory.cxx
 #  itkDICOMSeriesFileNames.cxx
@@ -27,16 +27,16 @@ SET(ITKIO_SRCS
   itkGE5ImageIOFactory.cxx
   itkGEAdwImageIO.cxx
   itkGEAdwImageIOFactory.cxx
-  itkGiplImageIO.cxx
-  itkGiplImageIOFactory.cxx
+#  itkGiplImageIO.cxx
+#  itkGiplImageIOFactory.cxx
   itkIOCommon.cxx
   itkIPLCommonImageIO.cxx
   itkIPLFileNameList.cxx
   itkImageIOBase.cxx
   itkImageIOFactory.cxx
   itkImageIORegion.cxx
-  itkJPEGImageIO.cxx
-  itkJPEGImageIOFactory.cxx
+#  itkJPEGImageIO.cxx
+#  itkJPEGImageIOFactory.cxx
 #  itkLSMImageIO.cxx
 #  itkLSMImageIOFactory.cxx
 #  itkMetaImageIO.cxx
@@ -44,8 +44,8 @@ SET(ITKIO_SRCS
 #  itkNrrdImageIO.cxx
 #  itkNrrdImageIOFactory.cxx
   itkNumericSeriesFileNames.cxx
-  itkPNGImageIO.cxx
-  itkPNGImageIOFactory.cxx
+#  itkPNGImageIO.cxx
+#  itkPNGImageIOFactory.cxx
   itkPolygonGroupSpatialObjectXMLFile.cxx
   itkRegularExpressionSeriesFileNames.cxx
   itkSiemensVisionImageIO.cxx
@@ -85,27 +85,27 @@ IF( OTB_USE_EXTERNAL_EXPAT )
 TARGET_LINK_LIBRARIES(ITKIO
 #ITKNrrdIO
 #${ITK_GDCM_LIBRARIES}
-${ITK_PNG_LIBRARIES}
+#${ITK_PNG_LIBRARIES}
 #${ITK_TIFF_LIBRARIES}
 ITKSpatialObject
 #ITKMetaIO
 #ITKDICOMParser
 ${EXPAT_LIBRARY}
 #ITKniftiio
-itkjpeg8
+#itkjpeg8
 )
 ELSE( OTB_USE_EXTERNAL_EXPAT  )
     TARGET_LINK_LIBRARIES(ITKIO
 #    ITKNrrdIO
 #    ${ITK_GDCM_LIBRARIES}
-    ${ITK_PNG_LIBRARIES}
+#    ${ITK_PNG_LIBRARIES}
 #    ${ITK_TIFF_LIBRARIES}
     ITKSpatialObject
 #    ITKMetaIO
 #    ITKDICOMParser
     otbexpat
 #    ITKniftiio
-    itkjpeg8
+#    itkjpeg8
 )
 ENDIF( OTB_USE_EXTERNAL_EXPAT )
 
diff --git a/Utilities/ITK/Code/IO/itkImageIOFactory.cxx b/Utilities/ITK/Code/IO/itkImageIOFactory.cxx
index 269b4f0112acc0259c9d523d6234635868418e61..eeaffc033d9cc80536c56a476bbadf954167b0ea 100644
--- a/Utilities/ITK/Code/IO/itkImageIOFactory.cxx
+++ b/Utilities/ITK/Code/IO/itkImageIOFactory.cxx
@@ -27,10 +27,10 @@
 //#include "itkAnalyzeImageIOFactory.h"
 //#include "itkNiftiImageIOFactory.h"
 //#include "itkGiplImageIOFactory.h"
-#include "itkJPEGImageIOFactory.h"
+//#include "itkJPEGImageIOFactory.h"
 //#include "itkLSMImageIOFactory.h"
 //#include "itkMetaImageIOFactory.h"
-#include "itkPNGImageIOFactory.h"
+//#include "itkPNGImageIOFactory.h"
 //#include "itkNrrdImageIOFactory.h"
 //#include "itkTIFFImageIOFactory.h"
 #include "itkVTKImageIOFactory.h"
@@ -102,7 +102,7 @@ ImageIOFactory::RegisterBuiltInFactories()
 //      ObjectFactoryBase::RegisterFactory( BioRadImageIOFactory::New() ); //should be before GDCM
 //      ObjectFactoryBase::RegisterFactory( GDCMImageIOFactory::New() );
 //      ObjectFactoryBase::RegisterFactory( MetaImageIOFactory::New() );
-      ObjectFactoryBase::RegisterFactory( PNGImageIOFactory::New() );
+//      ObjectFactoryBase::RegisterFactory( PNGImageIOFactory::New() );
       ObjectFactoryBase::RegisterFactory( VTKImageIOFactory::New() );
 //      ObjectFactoryBase::RegisterFactory( GiplImageIOFactory::New() );
 //      ObjectFactoryBase::RegisterFactory( LSMImageIOFactory::New()); //should be before TIFF
@@ -115,7 +115,7 @@ ImageIOFactory::RegisterBuiltInFactories()
 //      ObjectFactoryBase::RegisterFactory( AnalyzeImageIOFactory::New());
 //      ObjectFactoryBase::RegisterFactory( NiftiImageIOFactory::New());
 //      ObjectFactoryBase::RegisterFactory( StimulateImageIOFactory::New());
-      ObjectFactoryBase::RegisterFactory( JPEGImageIOFactory::New());
+//      ObjectFactoryBase::RegisterFactory( JPEGImageIOFactory::New());
 //      ObjectFactoryBase::RegisterFactory( TIFFImageIOFactory::New());
 //      ObjectFactoryBase::RegisterFactory( NrrdImageIOFactory::New() );
 //      ObjectFactoryBase::RegisterFactory( BMPImageIOFactory::New() );
diff --git a/Utilities/ITK/Code/IO/itkTransformFileReader.cxx b/Utilities/ITK/Code/IO/itkTransformFileReader.cxx
index 37709baabf27589321b45e7dc43f6470dc3173ae..da9ee6e708e0eb566916718e1368eee44f86098f 100644
--- a/Utilities/ITK/Code/IO/itkTransformFileReader.cxx
+++ b/Utilities/ITK/Code/IO/itkTransformFileReader.cxx
@@ -21,6 +21,7 @@
 #include "itkTransformBase.h"
 #include "itkTransformFactoryBase.h"
 
+#include <itksys/ios/fstream>
 #include <itksys/ios/sstream>
 
 namespace itk
diff --git a/Utilities/ITK/Code/IO/itkTransformFileReader.h b/Utilities/ITK/Code/IO/itkTransformFileReader.h
index 2f98fea780a25d3703dfaa74e9f55e1a6665cb2f..04d040248e888dedda46a0e72df59db8a3d709c5 100644
--- a/Utilities/ITK/Code/IO/itkTransformFileReader.h
+++ b/Utilities/ITK/Code/IO/itkTransformFileReader.h
@@ -27,7 +27,6 @@
 #else
 
 #include "itkLightProcessObject.h"
-#include "metaTransform.h"
 #include "itkTransformBase.h"
 
 namespace itk
diff --git a/Utilities/ITK/Code/IO/itkTransformFileWriter.cxx b/Utilities/ITK/Code/IO/itkTransformFileWriter.cxx
index b2f8c63fedd840fca64b3f6c38b667c40883785a..3fbe28a3f380908fa0f66585bb68ba26c5020d11 100644
--- a/Utilities/ITK/Code/IO/itkTransformFileWriter.cxx
+++ b/Utilities/ITK/Code/IO/itkTransformFileWriter.cxx
@@ -18,6 +18,7 @@
 #define __itkTransformFileWriter_cxx
 
 #include "itkTransformFileWriter.h"
+#include <itksys/ios/fstream>
 
 namespace itk
 {
diff --git a/Utilities/ITK/Code/IO/itkTransformFileWriter.h b/Utilities/ITK/Code/IO/itkTransformFileWriter.h
index a6a09ea8aa4a075fad5cbb8b083a7b06eb3ee059..678bd95ba7c6faadc2e636bd00a5ae35dfd05053 100644
--- a/Utilities/ITK/Code/IO/itkTransformFileWriter.h
+++ b/Utilities/ITK/Code/IO/itkTransformFileWriter.h
@@ -28,7 +28,6 @@
 
 
 #include "itkLightProcessObject.h"
-#include "metaTransform.h"
 #include "itkTransformBase.h"
 
 namespace itk
diff --git a/Utilities/ITK/Code/Review/CMakeLists.txt b/Utilities/ITK/Code/Review/CMakeLists.txt
index 8814c68088a467362001eeab090205c3ccb4e364..902379d51c286307218338628709ffc1f29c9480 100644
--- a/Utilities/ITK/Code/Review/CMakeLists.txt
+++ b/Utilities/ITK/Code/Review/CMakeLists.txt
@@ -4,11 +4,11 @@
 SET(ITKIOReview_SRCS
   itkBruker2DSEQImageIO.cxx
   itkBruker2DSEQImageIOFactory.cxx
-  itkPhilipsRECImageIO.cxx
-  itkPhilipsRECImageIOFactory.cxx
+#  itkPhilipsRECImageIO.cxx
+#  itkPhilipsRECImageIOFactory.cxx
   itkPhilipsPAR.cxx
-  itkVoxBoCUBImageIO.cxx
-  itkVoxBoCUBImageIOFactory.cxx
+#  itkVoxBoCUBImageIO.cxx
+#  itkVoxBoCUBImageIOFactory.cxx
   itkGaborKernelFunction.cxx
   itkMRCHeaderObject.cxx
   itkMRCImageIO.cxx
diff --git a/Utilities/ITK/Utilities/CMakeLists.txt b/Utilities/ITK/Utilities/CMakeLists.txt
index abbad1cfee8b438672dabfe53d0d99bdad42aa5f..1228d09c2e61a81b17844290ee7ddda9cada8d63 100644
--- a/Utilities/ITK/Utilities/CMakeLists.txt
+++ b/Utilities/ITK/Utilities/CMakeLists.txt
@@ -39,13 +39,13 @@ ADD_SUBDIRECTORY(kwsys)
 
 #------------------------------------------------------------------------------
 # Build jpeg first because tiff needs it
-ADD_SUBDIRECTORY(itkjpeg)
+#ADD_SUBDIRECTORY(itkjpeg)
 
 #------------------------------------------------------------------------------
 # Build third-party utilities.
 
-ITK_THIRD_PARTY_SUBDIR(ZLIB itkzlib)
-ITK_THIRD_PARTY_SUBDIR(PNG  itkpng)
+#ITK_THIRD_PARTY_SUBDIR(ZLIB itkzlib)
+#ITK_THIRD_PARTY_SUBDIR(PNG  itkpng)
 #ITK_THIRD_PARTY_SUBDIR(TIFF itktiff)
 SET(OPJ_PREFIX "itk")
 #ITK_THIRD_PARTY_SUBDIR(OpenJPEG openjpeg)
@@ -108,9 +108,9 @@ ADD_SUBDIRECTORY(KWStyle)
 
 #------------------------------------------------------------------------------
 # Create the DICOMParse library for ITK
-SET(DICOMPARSER_NAMESPACE itkdicomparser)
-SET(DICOMPARSER_LIBRARY ITKDICOMParser)
-SET(DICOMPARSER_STANDALONE 0)
+#SET(DICOMPARSER_NAMESPACE itkdicomparser)
+#SET(DICOMPARSER_LIBRARY ITKDICOMParser)
+#SET(DICOMPARSER_STANDALONE 0)
 #ADD_SUBDIRECTORY(DICOMParser)
 
 IF(ITK_DISABLE_CXX_TESTING)
@@ -159,9 +159,9 @@ ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL)
 IF(NOT ITK_INSTALL_NO_DEVELOPMENT)
   INSTALL(FILES
     ${ITK_BINARY_DIR}/Utilities/itkThirdParty.h
-    ${ITK_SOURCE_DIR}/Utilities/itk_zlib.h
+#    ${ITK_SOURCE_DIR}/Utilities/itk_zlib.h
 #    ${ITK_SOURCE_DIR}/Utilities/itk_tiff.h
-    ${ITK_SOURCE_DIR}/Utilities/itk_png.h
+#    ${ITK_SOURCE_DIR}/Utilities/itk_png.h
 #    ${ITK_SOURCE_DIR}/Utilities/metaIOConfig.h
 #    ${ITK_BINARY_DIR}/Utilities/NrrdIO/NrrdConfigure.h
     DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES}
diff --git a/Utilities/ITK/Utilities/itkThirdParty.h.in b/Utilities/ITK/Utilities/itkThirdParty.h.in
index f6a0cff37e21c442d9c812e65116e03284f6c058..43c83b42d884b6bf5c74f163cefd12518062275d 100644
--- a/Utilities/ITK/Utilities/itkThirdParty.h.in
+++ b/Utilities/ITK/Utilities/itkThirdParty.h.in
@@ -21,9 +21,11 @@
 #define __itkThirdParty_h
 
 /* Whether ITK is using its own utility libraries.  */
+/* OTB modification : remove ITK's png, jpg and tiff support since it is supported by GDAL
 #cmakedefine ITK_USE_SYSTEM_PNG
 #cmakedefine ITK_USE_SYSTEM_TIFF
 #cmakedefine ITK_USE_SYSTEM_ZLIB
+*/
 #cmakedefine ITK_USE_LIBXML2
 #cmakedefine ITK_USE_SYSTEM_LIBXML2
 
diff --git a/Utilities/ITK/itkIncludeDirectories.cmake b/Utilities/ITK/itkIncludeDirectories.cmake
index afd81128f7d6deb83712567f5a24e76a892ecaf3..1f8ebddf07e698e279f78bda7d6b09429b34318e 100644
--- a/Utilities/ITK/itkIncludeDirectories.cmake
+++ b/Utilities/ITK/itkIncludeDirectories.cmake
@@ -9,9 +9,9 @@ IF(ITK_USE_SYSTEM_VXL)
     )
 ENDIF(ITK_USE_SYSTEM_VXL)
 
-IF(ITK_USE_SYSTEM_GDCM)
-  SET(ITK_INCLUDE_DIRS_SYSTEM ${GDCM_DIR})
-ENDIF(ITK_USE_SYSTEM_GDCM)
+#IF(ITK_USE_SYSTEM_GDCM)
+#  SET(ITK_INCLUDE_DIRS_SYSTEM ${GDCM_DIR})
+#ENDIF(ITK_USE_SYSTEM_GDCM)
 
 #-----------------------------------------------------------------------------
 # Include directories from the build tree.
@@ -27,19 +27,19 @@ SET(ITK_INCLUDE_DIRS_BUILD_TREE ${ITK_INCLUDE_DIRS_BUILD_TREE}
   ${ITK_SOURCE_DIR}/Code/Numerics/FEM
   ${ITK_SOURCE_DIR}/Code/Numerics/NeuralNetworks
   ${ITK_SOURCE_DIR}/Code/SpatialObject
-  ${ITK_SOURCE_DIR}/Utilities/MetaIO
-  ${ITK_SOURCE_DIR}/Utilities/NrrdIO
-  ${ITK_BINARY_DIR}/Utilities/NrrdIO
-  ${ITK_SOURCE_DIR}/Utilities/DICOMParser
-  ${ITK_BINARY_DIR}/Utilities/DICOMParser
+#  ${ITK_SOURCE_DIR}/Utilities/MetaIO
+#  ${ITK_SOURCE_DIR}/Utilities/NrrdIO
+#  ${ITK_BINARY_DIR}/Utilities/NrrdIO
+#  ${ITK_SOURCE_DIR}/Utilities/DICOMParser
+#  ${ITK_BINARY_DIR}/Utilities/DICOMParser
 #  ${ITK_BINARY_DIR}/Utilities/expat
 #  ${ITK_SOURCE_DIR}/Utilities/expat
   ${ITK_SOURCE_DIR}/../otbexpat
-  ${ITK_SOURCE_DIR}/Utilities/nifti/niftilib
-  ${ITK_SOURCE_DIR}/Utilities/nifti/znzlib
+#  ${ITK_SOURCE_DIR}/Utilities/nifti/niftilib
+#  ${ITK_SOURCE_DIR}/Utilities/nifti/znzlib
   ${ITK_SOURCE_DIR}/Utilities/itkExtHdrs
   ${ITK_BINARY_DIR}/Utilities
-  ${ITK_SOURCE_DIR}/Utilities
+#  ${ITK_SOURCE_DIR}/Utilities
 )
 
 
diff --git a/Utilities/otbkml/CMakeLists.txt b/Utilities/otbkml/CMakeLists.txt
index 8be70c9d8b666d1d3c8d3969bdc0df03e61cd5c9..95b2c928a6ac9a125ef4d0c02518164a6a5b3557 100644
--- a/Utilities/otbkml/CMakeLists.txt
+++ b/Utilities/otbkml/CMakeLists.txt
@@ -13,7 +13,7 @@ SET(libkml_VERSION_STRING "${libkml_VERSION_MAJOR}.${libkml_VERSION_MINOR}.${lib
 
 # Allow sources in subdirectories to see the include files.
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/third_party)
+#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/third_party)
 IF(NOT OTB_USE_EXTERNAL_BOOST)
   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/third_party/boost_1_34_1)
 ELSE(NOT OTB_USE_EXTERNAL_BOOST)
diff --git a/otbIncludeDirectories.cmake b/otbIncludeDirectories.cmake
index 25ad43a13b3ecf2671df13b930a1171dd6a7eae4..3bd2cdc4922cbb76182a7a184390bcae786010f7 100644
--- a/otbIncludeDirectories.cmake
+++ b/otbIncludeDirectories.cmake
@@ -25,27 +25,28 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
 
 # These directories are always needed.
 SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
-  ${OTB_SOURCE_DIR}/Code/Common
   ${OTB_SOURCE_DIR}/Code/BasicFilters
-  ${OTB_SOURCE_DIR}/Code/IO
   ${OTB_SOURCE_DIR}/Code/ChangeDetection
+  ${OTB_SOURCE_DIR}/Code/Common
+  ${OTB_SOURCE_DIR}/Code/DisparityMap
   ${OTB_SOURCE_DIR}/Code/FeatureExtraction
+  ${OTB_SOURCE_DIR}/Code/Fusion
+  ${OTB_SOURCE_DIR}/Code/GeospatialAnalysis
+  ${OTB_SOURCE_DIR}/Code/Gui
+  ${OTB_SOURCE_DIR}/Code/IO
   ${OTB_SOURCE_DIR}/Code/Learning
+  ${OTB_SOURCE_DIR}/Code/Markov
   ${OTB_SOURCE_DIR}/Code/MultiScale
-  ${OTB_SOURCE_DIR}/Code/SpatialReasoning
-  ${OTB_SOURCE_DIR}/Code/DisparityMap
-  ${OTB_SOURCE_DIR}/Code/Visu
-  ${OTB_SOURCE_DIR}/Code/Visualization
-  ${OTB_SOURCE_DIR}/Code/Gui
-  ${OTB_SOURCE_DIR}/Code/Fusion
+  ${OTB_SOURCE_DIR}/Code/OBIA
   ${OTB_SOURCE_DIR}/Code/Projections
   ${OTB_SOURCE_DIR}/Code/Radiometry
   ${OTB_SOURCE_DIR}/Code/SARPolarimetry
-  ${OTB_SOURCE_DIR}/Code/Markov
-  ${OTB_SOURCE_DIR}/Code/GeospatialAnalysis
+  ${OTB_SOURCE_DIR}/Code/SpatialReasoning
   ${OTB_SOURCE_DIR}/Code/Testing
+  ${OTB_SOURCE_DIR}/Code/Visu
+  ${OTB_SOURCE_DIR}/Code/Visualization
+  ${OTB_BINARY_DIR}/Code/Visualization
   ${OTB_SOURCE_DIR}/Utilities/otbsvm
-  ${OTB_SOURCE_DIR}/Utilities/otbossim
   ${OTB_SOURCE_DIR}/Utilities/otbossim/include
   ${OTB_SOURCE_DIR}/Utilities/otbossim/include/ossim
   ${OTB_BINARY_DIR}/Utilities/otbossim/include/ossim
@@ -56,7 +57,6 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
   ${OTB_SOURCE_DIR}/Utilities/otb6S
   ${OTB_SOURCE_DIR}/Utilities/tinyXMLlib
 #  ${OTB_SOURCE_DIR}/Utilities/otbgalib
-  ${OTB_SOURCE_DIR}/Utilities/otbkml
   ${OTB_SOURCE_DIR}/Utilities/otbkml/src
   ${OTB_SOURCE_DIR}/Utilities/otbkml/third_party
   ${OTB_SOURCE_DIR}/Utilities/otbliblas/include
@@ -67,8 +67,6 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
   ${OTB_SOURCE_DIR}/Utilities/otbconfigfile
   ${OTB_SOURCE_DIR}/Utilities/otbknn
   ${OTB_SOURCE_DIR}/Utilities/otbmuparser
-  ${OTB_BINARY_DIR}/Code/Visualization
-  ${OTB_SOURCE_DIR}/Code/OBIA
 )
 
 
@@ -167,20 +165,20 @@ ELSE(OTB_USE_EXTERNAL_ITK)
         ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/vxl/v3p/netlib
         ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/vxl/vcl
         ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/vxl/core
-        ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/vxl/v3p/netlib
+#        ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/vxl/v3p/netlib
         ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/vxl/vcl
         ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/vxl/core
-        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities
+#        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities
         ${OTB_BINARY_DIR}/Utilities/ITK/Utilities
         ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/itkExtHdrs
-        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/DICOMParser
-        ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/DICOMParser
-        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/MetaIO
-        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/nifti/niftilib
-        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/nifti/znzlib
-        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/gdcm/src
-        ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/gdcm
-        ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/NrrdIO
+#        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/DICOMParser
+#        ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/DICOMParser
+#        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/MetaIO
+#        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/nifti/niftilib
+#        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/nifti/znzlib
+#        ${OTB_SOURCE_DIR}/Utilities/ITK/Utilities/gdcm/src
+#        ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/gdcm
+#        ${OTB_BINARY_DIR}/Utilities/ITK/Utilities/NrrdIO
         )
 ENDIF(OTB_USE_EXTERNAL_ITK)
 
@@ -416,14 +414,14 @@ ELSE(OTB_USE_EXTERNAL_ITK)
               Utilities/ITK/Utilities/vxl/core
               Utilities/ITK/Utilities
               Utilities/ITK/Utilities/itkExtHdrs
-              Utilities/ITK/Utilities/DICOMParser
-              Utilities/ITK/Utilities/MetaIO
-              Utilities/ITK/Utilities/nifti/niftilib
-              Utilities/ITK/Utilities/nifti/znzlib
-              Utilities/ITK/gdcm/src
-	      Utilities/ITK/gdcm
-              Utilities/ITK/Utilities/NrrdIO
-        )
+#              Utilities/ITK/Utilities/DICOMParser
+#              Utilities/ITK/Utilities/MetaIO
+#              Utilities/ITK/Utilities/nifti/niftilib
+#              Utilities/ITK/Utilities/nifti/znzlib
+#              Utilities/ITK/gdcm/src
+#              Utilities/ITK/gdcm
+#              Utilities/ITK/Utilities/NrrdIO 
+)
 
 # JULIEN Seems that ITK_INCLUDE_DIRS_CONFIG replaces ITK_INCLUDE_DIRS_INSTALL_TREE
 #             SET(ITK_INCLUDE_DIRS  ${OTB_INSTALL_INCLUDE_DIR}/Utilities/ITK/)