CMakeLists.txt 31.1 KB
Newer Older
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1 2 3
# This is the root OTB CMakeLists file.
# $Id$
#
4
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
5
IF(COMMAND CMAKE_POLICY)
6
  CMAKE_POLICY(SET CMP0003 NEW)
7
ENDIF(COMMAND CMAKE_POLICY)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

PROJECT(OTB)

INCLUDE_REGULAR_EXPRESSION("^(otb|itk|vtk|vnl|vcl|vxl|f2c|netlib|ce|itpack|DICOM|meta|png|dbh|tif|jpeg|zlib).*$")
SOURCE_GROUP("XML Files" REGULAR_EXPRESSION "[.]xml$")

# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
# warnings
IF(WIN32)
  IF(NOT BORLAND)
    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(NOT BORLAND)
ENDIF(WIN32)
38 39 40 41
# __CYGWIN__ must be define for ossim (ex: ossimCommon.h, isnan definition, .. )
#IF(CYGWIN)
#  ADD_DEFINITIONS(-D__CYGWIN__)
#ENDIF(CYGWIN)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
42 43

# If CMake is the version we're expecting, don't show the
44 45 46
# 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$")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
47
  MARK_AS_ADVANCED(FORCE CMAKE_BACKWARDS_COMPATIBILITY)
48
ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" MATCHES "^2\\.4$")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
49
  MARK_AS_ADVANCED(CLEAR CMAKE_BACKWARDS_COMPATIBILITY)
50
ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" MATCHES "^2\\.4$")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
51

52 53 54 55
#-----------------------------------------------------------------------------
# OTB option to access large file (> 4Go).
ADD_DEFINITIONS(
	-D_LARGEFILE_SOURCE
56
	-D_FILE_OFFSET_BITS=64
57
	-D_LARGEFILE64_SOURCE
58
	-D_LARGE_FILES
59
	)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
60 61 62

#-----------------------------------------------------------------------------
# OTB version number.  An even minor number corresponds to releases.
63
SET(OTB_VERSION_MAJOR "2")
64
SET(OTB_VERSION_MINOR "9")
Julien Michel's avatar
Julien Michel committed
65
SET(OTB_VERSION_PATCH "0")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
66

67

Thomas Feuvrier's avatar
Thomas Feuvrier committed
68 69 70 71
# 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}")

72

73
# => Comment for OTB 2.6.0
74
OPTION(BUILD_TESTING "Build testing." OFF)
75

76 77 78 79 80 81 82 83 84 85
#-----------------------------------------------------------------------------
# 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})
86 87 88 89 90

#-----------------------------------------------------------------------------

# Case for release 2.2.1
# Use the openjpeg library.
91
OPTION(OTB_USE_JPEG2000 "Use to support jpeg2000 image file format." ON)
92

Thomas Feuvrier's avatar
Thomas Feuvrier committed
93
#-----------------------------------------------------------------------------
94 95


96
# FIND EXTERNAL LIBRAIRIES USE
Thomas Feuvrier's avatar
Thomas Feuvrier committed
97

98 99 100 101
#-------------------------------
# EXPAT Library
#-------------------------------

102 103
OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." OFF)
MARK_AS_ADVANCED(OTB_USE_EXTERNAL_EXPAT)
104

105 106 107
IF(OTB_USE_EXTERNAL_EXPAT)
    FIND_PACKAGE(EXPAT)
    IF(EXPAT_FOUND)
108 109 110
        # Control expat compatibility
        INCLUDE_DIRECTORIES(BEFORE ${EXPAT_INCLUDE_DIR})
        LINK_DIRECTORIES( ${EXPAT_LIBRARY} )
111 112 113 114 115
    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)
116 117 118
        ADD_DEFINITIONS(-DOTB_USE_INTERNAL_EXPAT)
        INCLUDE_DIRECTORIES(BEFORE "${OTB_SOURCE_DIR}/Utilities/otbexpat")
        INCLUDE_DIRECTORIES(BEFORE "${OTB_BINARY_DIR}/Utilities/otbexpat")
119 120 121
	IF(NOT BUILD_SHARED_LIBS)
        	ADD_DEFINITIONS(-DXML_STATIC)
        ENDIF(NOT BUILD_SHARED_LIBS)
122
ENDIF(OTB_USE_EXTERNAL_EXPAT)
123

124 125 126 127 128 129 130 131
#-------------------------------
# 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)
132 133 134 135 136 137 138 139 140
        # 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}")

141 142 143 144 145
        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)
146 147 148 149
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)
150 151 152 153
ENDIF(OTB_USE_EXTERNAL_ITK)


# JPEG2000 specification control
OTB Bot's avatar
OTB Bot committed
154
SET(OTB_COMPILE_JPEG2000 0)
155 156 157 158 159 160 161
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$")
Julien Michel's avatar
Julien Michel committed
162
        MESSAGE(STATUS "WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
163 164 165
        SET(OTB_COMPILE_JPEG2000 0)
  ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio 7$")
  IF(CMAKE_GENERATOR MATCHES "^Visual Studio 7 .NET 2003$")
Julien Michel's avatar
Julien Michel committed
166
        MESSAGE(STATUS "WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
167 168
        SET(OTB_COMPILE_JPEG2000 0)
  ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio 7 .NET 2003$")
169
  IF(CYGWIN)
Julien Michel's avatar
Julien Michel committed
170
        MESSAGE(STATUS "WARNING: For cygwin, jpeg2000 support is disabled.")
171 172 173
        SET(OTB_COMPILE_JPEG2000 0)
  ENDIF(CYGWIN)

174
ENDIF( OTB_USE_JPEG2000 )
175
# Check jpeg2000 support
176 177
IF(OTB_COMPILE_JPEG2000)
  ADD_DEFINITIONS(-DOTB_COMPILE_JPEG2000 -DUSE_OPJ_DEPRECATED)
Thomas Feuvrier's avatar
Modif  
Thomas Feuvrier committed
178 179 180
  IF(NOT BUILD_SHARED_LIBS)
        ADD_DEFINITIONS(-DOPJ_STATIC)
  ENDIF(NOT BUILD_SHARED_LIBS)
181 182
ENDIF(OTB_COMPILE_JPEG2000)

183 184 185
#-----------------------------------------------------------------------------
# Option for OpenThreads (necessary because used by the new version of OSSIM library
# Find OpenThread library
186
IF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
187
        FIND_PACKAGE(OpenThreads)
188
ELSE(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
189
        INCLUDE(${OTB_SOURCE_DIR}/FindOpenThreads.cmake)
190
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
191 192 193 194 195 196 197 198 199 200 201

SET(OTB_USE_EXTERNAL_OPENTHREADS 1)
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 0)
        SET(OPENTHREADS_INCLUDE_DIR "${OTB_SOURCE_DIR}/Utilities/otbopenthreads/OpenThreads/include")
        SET(OPENTHREADS_LIBRARY "OpenThreads" )
        INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
202 203 204
	IF(NOT BUILD_SHARED_LIBS)
         ADD_DEFINITIONS(-DOT_LIBRARY_STATIC)
        ENDIF(NOT BUILD_SHARED_LIBS)
205
ENDIF(OPENTHREADS_FOUND)
206

207 208 209 210
IF(NOT BUILD_SHARED_LIBS)
  ADD_DEFINITIONS(-DOSSIM_STATIC)
ENDIF(NOT BUILD_SHARED_LIBS)

211

Thomas Feuvrier's avatar
Thomas Feuvrier committed
212 213
#-----------------------------------------------------------------------------
# Option for generate Visu tools !!!
214
OPTION(OTB_USE_VISU_GUI "Generate Gui/Visu tools directory. If ON, find OpenGL and FLTK packages." ON)
215
MARK_AS_ADVANCED(OTB_USE_VISU_GUI)
216

OTB Bot's avatar
OTB Bot committed
217
SET(OTB_GLU_INCLUDE_PATH "")
218
IF(OTB_USE_VISU_GUI)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
219 220

        #-------------------------------
221
        # OpenGL Library
Thomas Feuvrier's avatar
Thomas Feuvrier committed
222 223
        #-------------------------------
        FIND_PACKAGE(OpenGL)
224

Thomas Feuvrier's avatar
Thomas Feuvrier committed
225 226
        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 to OFF to disable OTB Visu module generation !")
227
	ENDIF( NOT OPENGL_FOUND )
Thomas Feuvrier's avatar
Thomas Feuvrier committed
228 229 230 231 232 233 234
        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 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)
235 236 237 238

	#-------------------------------
        # Display images using textures using video card acceleration
        #-------------------------------
239 240
	OPTION(OTB_GL_USE_ACCEL "Use video card acceleration." ON)
	MARK_AS_ADVANCED(OTB_GL_USE_ACCEL)
241

Thomas Feuvrier's avatar
Thomas Feuvrier committed
242
        #-------------------------------
Thomas Feuvrier's avatar
Thomas Feuvrier committed
243
        # FLTK Library
Thomas Feuvrier's avatar
Thomas Feuvrier committed
244
        #-------------------------------
245

246
        # Option for internal/external FLTK
247
        OPTION(OTB_USE_EXTERNAL_FLTK "Use an outside build of FLTK." ON)
248
#         MARK_AS_ADVANCED(OTB_USE_EXTERNAL_FLTK)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
249
        # Add an option to use or not use FLTK (http://www.fltk.org)
250 251 252
        IF(OTB_USE_EXTERNAL_FLTK)

                FIND_PACKAGE(FLTK)
253
                # Mingw Option doesn't exist in the FindFLTK.cmake default configuration file in CMake installationj directory.
254 255 256 257 258
                # Copy  FLTK_PLATFORM_DEPENDENT_LIBS from FLTK CmakeList.txt
                IF(MINGW)
                    ADD_DEFINITIONS(-DWIN32)
                    SET( FLTK_PLATFORM_DEPENDENT_LIBS ole32 uuid wsock32 gdi32 comdlg32)
                ENDIF(MINGW)
259 260
                IF (NOT FLTK_INCLUDE_DIR)
		        SET( FLTK_INCLUDE_DIR /usr/include )
261
                FIND_PACKAGE(FLTK)
262
	        ENDIF(NOT FLTK_INCLUDE_DIR)
263

Thomas Feuvrier's avatar
Thomas Feuvrier committed
264
                IF(FLTK_FOUND)
265 266 267 268 269 270
		        INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIRS})
		        LINK_DIRECTORIES(${FLTK_LIBRARY_DIRS})
                ELSE(FLTK_FOUND)
                        MESSAGE(FATAL_ERROR
	                        "Cannot build OTB project without FLTK.  Please set FLTK_DIR  or  set OTB_USE_VISU to OFF  or  set OTB_USE_EXTERNAL_FLTK OFF to use INTERNAL FLTK set on OTB/Utilities repository.")
                ENDIF(FLTK_FOUND)
271

272
        ELSE(OTB_USE_EXTERNAL_FLTK)
273

274
                SET( FLTK_PLATFORM_DEPENDENT_LIBS "")
275
                IF(EXISTS "${OTB_BINARY_DIR}/Utilities/FLTK/FLTKConfig.cmake")
276
                        INCLUDE(${OTB_BINARY_DIR}/Utilities/FLTK/FLTKConfig.cmake)
277
                ENDIF(EXISTS "${OTB_BINARY_DIR}/Utilities/FLTK/FLTKConfig.cmake")
278 279 280
                #----------------------------------------------------------------
                # RESUME Alls VISU GUI libraries use by OTB in a single VARIABLE
                SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES} ")
281

282
        ENDIF(OTB_USE_EXTERNAL_FLTK)
283

284 285
ENDIF(OTB_USE_VISU_GUI)

286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
#-------------------------------
# CURL Library
#-------------------------------
OPTION(OTB_USE_CURL "Use curl library." OFF)
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)

307
        # Add compiler option
308 309 310 311 312 313 314 315 316 317 318
        ADD_DEFINITIONS(-DOTB_USE_CURL)

        INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})

ENDIF(OTB_USE_CURL)

#-------------------------------
# GDAL Library
#-------------------------------

FIND_PATH(GDAL_INCLUDE_DIRS gdal.h $ENV{GDAL_INCLUDE_DIRS} /usr/include/gdal)
319

320 321 322 323 324 325 326
IF (NOT GDAL_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR
         "Cannot find GDAL include directory. Please set GDAL_INCLUDE_DIRS.")
ENDIF (NOT GDAL_INCLUDE_DIRS)

INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIRS})

327
FIND_LIBRARY(GDAL_LIBRARY NAMES gdal gdal1.6.0 gdal1.5.0 gdal1.4.0 gdal1.3.2 PATHS /usr/lib/gdal)
328

329 330 331 332 333
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}")
334

335
# Find geotiff headers
336
FIND_PATH(GEOTIFF_INCLUDE_DIRS geotiff.h $ENV{GDAL_INCLUDE_DIRS} ${GDAL_INCLUDE_DIRS} /usr/include/geotiff)
337 338 339 340 341 342 343
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
344
FIND_PATH(TIFF_INCLUDE_DIRS tiffio.h $ENV{GDAL_INCLUDE_DIRS} ${GDAL_INCLUDE_DIRS} /usr/include)
345 346 347 348 349 350
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})

351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
# Find jpeg headers
FIND_PATH(JPEG_INCLUDE_DIRS jpeglib.h $ENV{GDAL_INCLUDE_DIRS} ${GDAL_INCLUDE_DIRS} /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_DIRS} ${GDAL_INCLUDE_DIRS} /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})

367
# Check if ${GDAL_LIBRARY} has tiff library
368
TRY_COMPILE(GDAL_HAS_TIFF
369
${CMAKE_CURRENT_BINARY_DIR}CMake
370
${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasTiff.cxx
371
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${TIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
372 373
OUTPUT_VARIABLE OUTPUT)
IF(GDAL_HAS_TIFF)
374
MESSAGE(STATUS "Testing if GDAL has tiff    -- yes")
375
SET(TIFF_LIBRARY ${GDAL_LIBRARY})
376
ELSE(GDAL_HAS_TIFF)
377
MESSAGE(STATUS "Testing if GDAL has tiff    -- no")
378 379 380 381 382 383 384
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)

385
# Check if ${GDAL_LIBRARY} has geotiff library
386
TRY_COMPILE(GDAL_HAS_GEOTIFF
387
${CMAKE_CURRENT_BINARY_DIR}/CMake
388
${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasGeoTiff.cxx
389
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GEOTIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
390 391
OUTPUT_VARIABLE OUTPUT)
IF(GDAL_HAS_GEOTIFF)
392
MESSAGE(STATUS "Testing if GDAL has geotiff -- yes")
393
SET(GEOTIFF_LIBRARY ${GDAL_LIBRARY})
394
ELSE(GDAL_HAS_GEOTIFF)
395
MESSAGE(STATUS "Testing if GDAL has geotiff -- no")
396 397 398
FIND_LIBRARY(GEOTIFF_LIBRARY geotiff PATHS)
IF (NOT GEOTIFF_LIBRARY)
MESSAGE(FATAL_ERROR
399
         "Cannot find geotiff library. Please set GEOTIFF_LIBRARY.")
400 401
ENDIF (NOT GEOTIFF_LIBRARY)
ENDIF(GDAL_HAS_GEOTIFF)
402

403 404 405 406
# Check if ${GDAL_LIBRARY} has jpeg library
TRY_COMPILE(GDAL_HAS_JPEG
${CMAKE_CURRENT_BINARY_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasJpeg.cxx
407
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${JPEG_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
408 409 410
OUTPUT_VARIABLE OUTPUT)
IF(GDAL_HAS_JPEG)
MESSAGE(STATUS "Testing if GDAL has jpeg    -- yes")
411
SET(JPEG_LIBRARY ${GDAL_LIBRARY})
412 413 414 415 416 417 418 419 420 421 422 423 424 425
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 jpeg library
SET(OGR_LIBRARY ${GDAL_LIBRARY})
TRY_COMPILE(GDAL_HAS_OGR
${CMAKE_CURRENT_BINARY_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasOGR.cxx
426
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${OGR_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
427 428 429 430 431 432 433 434 435 436 437 438
OUTPUT_VARIABLE OUTPUT)
IF(GDAL_HAS_OGR)
MESSAGE(STATUS "Testing if GDAL has OGR     -- yes")
ELSE(GDAL_HAS_OGR)
MESSAGE(STATUS "Testing if GDAL has OGR     -- no")
MESSAGE(${OUTPUT})
FIND_LIBRARY(OGR_LIBRARY ogr PATHS)
IF (NOT OGR_LIBRARY)
MESSAGE(FATAL_ERROR
         "Cannot find jpeg library. Please set OGR_LIBRARY.")
ENDIF (NOT OGR_LIBRARY)
ENDIF(GDAL_HAS_OGR)
439

440

Thomas Feuvrier's avatar
Thomas Feuvrier committed
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
#-------------------------------
# End connections whith external libraries
#-------------------------------

# 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 /usr/local/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_DIRECTORIES (
492
  ${OTB_BINARY_DIR}
Thomas Feuvrier's avatar
Thomas Feuvrier committed
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
  ${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)
509
IF(BUILD_TESTING)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
510 511 512
  ENABLE_TESTING()
  SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
  MARK_AS_ADVANCED(BUILDNAME)
513
ENDIF(BUILD_TESTING)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529


#-----------------------------------------------------------------------------
# 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)

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.
530
   SET(OTB_LIBRARY_PROPERTIES
Thomas Feuvrier's avatar
Thomas Feuvrier committed
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
       VERSION   "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH}"
       SOVERSION "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
ENDIF(NOT OTB_NO_LIBRARY_VERSION)




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})

INCLUDE_DIRECTORIES( ${OTB_LIBRARY_PATH} )

# Put "." in the rpath of all OTB shared libraries.
LINK_DIRECTORIES(.)

#-----------------------------------------------------------------------------
# Option for display all developpment message !!!
551
OPTION(OTB_SHOW_ALL_MSG_DEBUG "OTB developers : Show all messages (debug, dev, etc...) use only for otb developers." OFF)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
552
MARK_AS_ADVANCED(OTB_SHOW_ALL_MSG_DEBUG)
553 554 555
# IF( OTB_SHOW_ALL_MSG_DEBUG )
#  ADD_DEFINITIONS(-DOTB_SHOW_ALL_MSG_DEBUG)
# ENDIF( OTB_SHOW_ALL_MSG_DEBUG )
Thomas Feuvrier's avatar
Thomas Feuvrier committed
556

557 558 559 560 561 562
#-----------------------------------------------------------------------------
# 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)
563
MESSAGE("Warning: utilities compilation is disabled.")
564 565 566 567
LINK_DIRECTORIES("${OTB_BINARY_DIR}/bin")
ENDIF(OTB_DISABLE_UTILITIES_COMPILATION)


568 569 570
#-----------------------------------------------------------------------------
# Option to define streaming activation in applications
# Use by otbConfigure.h.in
571
SET(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING 8*4000*4000 CACHE STRING "Image size to activate using streaming for applications.")
572
MARK_AS_ADVANCED(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING)
573
SET(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING 8*4000*4000 CACHE STRING "Max size buffer for streaming.")
574 575 576
MARK_AS_ADVANCED(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING)


577 578 579 580 581 582 583 584

#-----------------------------------------------------------------------------
# Perform a setup of OTB Wrapping. This will provide CMake options for
# individual wrapping as well as determine if CableSwig is required. If it is,
# OTB_NEED_CableSwig will be set. This file also tries to locate CableSwig by
# searching first in the source tree of OTB, and if that fails, it searches
# for a binary built of CableSwig.
#
Julien Michel's avatar
oubli  
Julien Michel committed
585
INCLUDE(${OTB_SOURCE_DIR}/Wrapping/otbWrapSetup.cmake)
586 587


Thomas Feuvrier's avatar
Thomas Feuvrier committed
588 589 590 591 592
#-----------------------------------------------------------------------------
# Option for generate Patented examples  !!!
OPTION(OTB_USE_PATENTED "Build patented examples. ITK must be genereted whith patented option (ITK_USE_PATENTED = ON)." OFF)
MARK_AS_ADVANCED(OTB_USE_PATENTED)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
593 594 595
IF(OTB_USE_VISU_GUI)
    SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES};${FLTK_PLATFORM_DEPENDENT_LIBS}")
        IF(APPLE)
596
            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")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
597 598 599 600 601
        ENDIF(APPLE)
ELSE(OTB_USE_VISU_GUI)
        SET(OTB_VISU_GUI_LIBRARIES "")
ENDIF(OTB_USE_VISU_GUI)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
602

603 604 605 606 607 608
#-----------------------------------------------------------------------------
# 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
609

610
SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${GDAL_LIBRARY};dxf;tinyXML;otbliblas;otbossim;otbossimplugins" )
611 612 613 614

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)
615

616
# Add EXPAT library
617
IF( OTB_USE_EXTERNAL_EXPAT )
618
        SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES  "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};expat")
619
ELSE( OTB_USE_EXTERNAL_EXPAT  )
620
        SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES  "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};otbexpat")
621
ENDIF( OTB_USE_EXTERNAL_EXPAT )
622

623 624
# Add Open Jpeg library
IF( OTB_COMPILE_JPEG2000 )
625
     SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};otbopenjpeg")
626 627
ENDIF( OTB_COMPILE_JPEG2000 )

628
# => Create OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES
629
SET(OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES "otb6S;otbgalib;InsightJournal;otbsvm")
630 631 632 633 634


# => Create OTB_ALLS_UTILITIES_DEPENDENT_LIBRARIES
SET(OTB_ALLS_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES} ${OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES}")

635

636
#-----------------------------------------------------------------------------
637
OPTION(BUILD_EXAMPLES "Build the Examples directory." OFF)
638

Thomas Feuvrier's avatar
Thomas Feuvrier committed
639 640 641

#-----------------------------------------------------------------------------
# Dispatch the build into the proper subdirectories.
642

Thomas Feuvrier's avatar
Thomas Feuvrier committed
643 644
SUBDIRS(Utilities Code)

645 646
SUBDIRS(Wrapping)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
647 648 649 650 651 652 653 654 655
IF (BUILD_EXAMPLES)
  SUBDIRS(Examples)
ENDIF (BUILD_EXAMPLES)

IF (BUILD_TESTING)
  SUBDIRS(Testing)
ENDIF (BUILD_TESTING)

#-----------------------------------------------------------------------------
656
# => Comment for OTB 2.6.0: simplification : copy ITK values
Thomas Feuvrier's avatar
Thomas Feuvrier committed
657
# OTB requires special compiler flags on some platforms.
658 659 660 661
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}")

Thomas Feuvrier's avatar
Thomas Feuvrier committed
662 663 664 665
IF(MINGW)
  LINK_LIBRARIES(gdi32)
ENDIF(MINGW)

666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
#-----------------------------------------------------------------------------
# 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)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
684 685 686 687 688 689


INCLUDE(CheckTypeSize)

CHECK_TYPE_SIZE("long long" OTB_SIZEOF_LONG_LONG)
CHECK_TYPE_SIZE("__int64"   OTB_SIZEOF___INT64)
Julien Michel's avatar
Julien Michel committed
690 691
CHECK_TYPE_SIZE("long int" OTB_SIZEOF_LONG_INT)
CHECK_TYPE_SIZE("short int" OTB_SIZEOF_SHORT_INT)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
692 693 694 695 696 697

#-----------------------------------------------------------------------------
# Configure the default OTB_DATA_ROOT for the location of OTB Data.
FIND_PATH(OTB_DATA_ROOT OTBData.readme $ENV{OTB_DATA_ROOT})
MARK_AS_ADVANCED(OTB_DATA_ROOT)

698 699 700 701 702 703 704
OPTION(OTB_DATA_USE_LARGEINPUT "Use Large inputs images test." OFF)
MARK_AS_ADVANCED(OTB_DATA_USE_LARGEINPUT)
IF(OTB_DATA_USE_LARGEINPUT)
  FIND_PATH(OTB_DATA_LARGEINPUT_ROOT OTBData.readme $ENV{OTB_DATA_LARGEINPUT_ROOT})
  MARK_AS_ADVANCED(OTB_DATA_LARGEINPUT_ROOT)
ENDIF(OTB_DATA_USE_LARGEINPUT)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
705 706 707

#-----------------------------------------------------------------------------
# Configure files with settings for use by the build.
708
CONFIGURE_FILE(${OTB_SOURCE_DIR}/otbConfigure.h.in
Thomas Feuvrier's avatar
Thomas Feuvrier committed
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
               ${OTB_BINARY_DIR}/otbConfigure.h)

#-----------------------------------------------------------------------------
# The entire OTB tree should use the same include path, except for the
# Wrapping directory.

# 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(
  "${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

#-----------------------------------------------------------------------------
# Help other projects use OTB.

# Copy the UseOTB.cmake file to the binary tree for backward compatability.
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)

# Save library dependencies.
EXPORT_LIBRARY_DEPENDENCIES(${OTB_BINARY_DIR}/OTBLibraryDepends.cmake)

# Create the OTBConfig.cmake file containing the OTB configuration.
INCLUDE (${OTB_SOURCE_DIR}/otbGenerateOTBConfig.cmake)

# Install some files.
INSTALL_FILES(/include/otb .h otbConfigure)
INSTALL_FILES(/lib/otb .cmake UseOTB OTBLibraryDepends OTBConfig )

#-----------------------------------------------------------------------------
# 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}")
768 769

#-----------------------------------------------------------------------------
770 771 772 773
# Set up CPack support, to be able to distribute OTB binary packages. It will
# be particulary useful to distributed prebuilt OTB.
#

774
#INCLUDE(InstallRequiredSystemLibraries)
775

776 777 778
SET(CPACK_PACKAGE_NAME "OTB" CACHE STRING "Package name")
MARK_AS_ADVANCED(CPACK_PACKAGE_NAME)

779 780 781 782 783 784 785
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}")
786 787 788 789

SET(CPACK_PACKAGE_CONTACT "debian@orfeo-toolbox.org" CACHE STRING  "Debian package maintainer email")
MARK_AS_ADVANCED(CPACK_PACKAGE_CONTACT)

790
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Description.txt")
791

792
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "lib${GDAL_LIBRARY}1-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" )
793 794
MARK_AS_ADVANCED(CPACK_DEBIAN_PACKAGE_DEPENDS)

795 796 797 798
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "OrfeoToolbox-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")

SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright/OTBCopyright.txt")

799 800 801
FILE(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
FILE(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_DEBIAN_PACKAGE_DESCRIPTION)

802 803
INCLUDE(CPack)