CMakeLists.txt 37.7 KB
Newer Older
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1
2
3
# This is the root OTB CMakeLists file.
# $Id$
#
4
5
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
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
38
39

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)

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

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

#-----------------------------------------------------------------------------
# OTB version number.  An even minor number corresponds to releases.
59
SET(OTB_VERSION_MAJOR "2")
Julien Michel's avatar
Julien Michel committed
60
61
SET(OTB_VERSION_MINOR "4")
SET(OTB_VERSION_PATCH "0")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
62

63

Thomas Feuvrier's avatar
Thomas Feuvrier committed
64
65
66
67
# 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}")

68

69
# => Comment for OTB 2.6.0
70
#OPTION(BUILD_TESTING "Build testing." OFF)
71

72
73
74
75
76

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

# Case for release 2.2.1
# Use the openjpeg library.
77
OPTION(OTB_USE_JPEG2000 "Use to support jpeg2000 image file format." ON)
78
#MARK_AS_ADVANCED(OTB_USE_JPEG2000)
79

Thomas Feuvrier's avatar
Thomas Feuvrier committed
80
#-----------------------------------------------------------------------------
81
82


83
# FIND EXTERNAL LIBRAIRIES USE
Thomas Feuvrier's avatar
Thomas Feuvrier committed
84

85
86
87
88
#-------------------------------
# EXPAT Library
#-------------------------------

89
90
91
92
93
94
OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." OFF)
MARK_AS_ADVANCED(OTB_USE_EXTERNAL_EXPAT)
#SET(OTB_COMPILE_EXPAT ${OTB_USE_EXTERNAL_EXPAT})
IF(OTB_USE_EXTERNAL_EXPAT)
    FIND_PACKAGE(EXPAT)
    IF(EXPAT_FOUND)
95
96
97
        # Control expat compatibility
        INCLUDE_DIRECTORIES(BEFORE ${EXPAT_INCLUDE_DIR})
        LINK_DIRECTORIES( ${EXPAT_LIBRARY} )
98
99
100
101
102
103
104
105
106
107
108
#        TRY_COMPILE(OTB_TYPE_COMPILE_EXPAT
#                        ${OTB_BINARY_DIR}/CMakeTmp
#                        ${OTB_SOURCE_DIR}/CMake/otbTestCompileExpat.cxx )
#        IF( NOT OTB_TYPE_COMPILE_EXPAT)
#            SET(OTB_USE_EXTERNAL_EXPAT OFF)
#        ENDIF( NOT OTB_TYPE_COMPILE_EXPAT)
    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)
109
110
111
        ADD_DEFINITIONS(-DOTB_USE_INTERNAL_EXPAT)
        INCLUDE_DIRECTORIES(BEFORE "${OTB_SOURCE_DIR}/Utilities/otbexpat")
        INCLUDE_DIRECTORIES(BEFORE "${OTB_BINARY_DIR}/Utilities/otbexpat")
112
ENDIF(OTB_USE_EXTERNAL_EXPAT)
113

114
115
116
117
118
119
120
121
#-------------------------------
# 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)
122
123
124
125
126
127
128
129
130
        # 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}")

131
132
133
134
135
        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)
136
137
138
139
ENDIF(OTB_USE_EXTERNAL_ITK)


# JPEG2000 specification control
OTB Bot's avatar
OTB Bot committed
140
SET(OTB_COMPILE_JPEG2000 0)
141
142
143
144
145
146
147
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
148
        MESSAGE(STATUS "WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
149
150
151
        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
152
        MESSAGE(STATUS "WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
153
154
        SET(OTB_COMPILE_JPEG2000 0)
  ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio 7 .NET 2003$")
155
  IF(CYGWIN)
Julien Michel's avatar
Julien Michel committed
156
        MESSAGE(STATUS "WARNING: For cygwin, jpeg2000 support is disabled.")
157
158
159
        SET(OTB_COMPILE_JPEG2000 0)
  ENDIF(CYGWIN)

160
161
162
163
ENDIF( OTB_USE_JPEG2000 )
# Check jpeg2000 support 
IF(OTB_COMPILE_JPEG2000)
  ADD_DEFINITIONS(-DOTB_COMPILE_JPEG2000 -DUSE_OPJ_DEPRECATED)
Thomas Feuvrier's avatar
Modif    
Thomas Feuvrier committed
164
165
166
  IF(NOT BUILD_SHARED_LIBS)
        ADD_DEFINITIONS(-DOPJ_STATIC)
  ENDIF(NOT BUILD_SHARED_LIBS)
167
168
ENDIF(OTB_COMPILE_JPEG2000)

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#-----------------------------------------------------------------------------
# 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}/FindOpenThreads.cmake)
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake") 

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})
188
189
190
	IF(NOT BUILD_SHARED_LIBS)
         ADD_DEFINITIONS(-DOT_LIBRARY_STATIC)
        ENDIF(NOT BUILD_SHARED_LIBS)
191
ENDIF(OPENTHREADS_FOUND)
192

193
194
195
196
IF(NOT BUILD_SHARED_LIBS)
  ADD_DEFINITIONS(-DOSSIM_STATIC)
ENDIF(NOT BUILD_SHARED_LIBS)

197

Thomas Feuvrier's avatar
Thomas Feuvrier committed
198
199
#-----------------------------------------------------------------------------
# Option for generate Visu tools !!!
200
OPTION(OTB_USE_VISU_GUI "Generate Gui/Visu tools directory. If ON, find OpenGL and FLTK packages." ON)
201
MARK_AS_ADVANCED(OTB_USE_VISU_GUI)
202

OTB Bot's avatar
OTB Bot committed
203
SET(OTB_GLU_INCLUDE_PATH "")
204
IF(OTB_USE_VISU_GUI)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
205
206

        #-------------------------------
207
        # OpenGL Library
Thomas Feuvrier's avatar
Thomas Feuvrier committed
208
209
        #-------------------------------
        FIND_PACKAGE(OpenGL)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
        
        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 !")
        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 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)

#        INCLUDE(CheckIncludeFiles)
#        CHECK_INCLUDE_FILES("GL/glu.h"       HAVE_GL_GLU_H)
#        IF ( NOT HAVE_GL_GLU_H )
#                FIND_PATH(OTB_GLU_INCLUDE_PATH "GL/glu.h" ${OPENGL_INCLUDE_PATH})
#                IF(NOT OTB_GLU_INCLUDE_PATH)
#                        SET(OTB_GLU_INCLUDE_PATH "")
#                        MESSAGE("Impossible to find GLU files (include lib), detected by the FIND_PACKAGE(OpenGL) command.\nCannot build OTB Visu module without GLU library.\n=> You must install GLU (Mesa package, etc.) on your system OR set OTB_USE_VISU to OFF to disable OTB Visu module generation !")
#                ENDIF(NOT OTB_GLU_INCLUDE_PATH)
#        ENDIF ( NOT HAVE_GL_GLU_H )
OTB Bot's avatar
OTB Bot committed
231

232
        
Thomas Feuvrier's avatar
Thomas Feuvrier committed
233
        #-------------------------------
Thomas Feuvrier's avatar
Thomas Feuvrier committed
234
        # FLTK Library
Thomas Feuvrier's avatar
Thomas Feuvrier committed
235
        #-------------------------------
236
237
238
239

        # Option for internal/external FLTK 
        OPTION(OTB_USE_EXTERNAL_FLTK "Use an outside build of FLTK." ON)
        MARK_AS_ADVANCED(OTB_USE_EXTERNAL_FLTK)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
240
        # Add an option to use or not use FLTK (http://www.fltk.org)
241
242
243
        IF(OTB_USE_EXTERNAL_FLTK)

                FIND_PACKAGE(FLTK)
244
245
246
247
248
249
                # Mingw Option doesn't exist in the FindFLTK.cmake default configuration file in CMake installationj directory. 
                # 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)
250
251
                IF (NOT FLTK_INCLUDE_DIR)
		        SET( FLTK_INCLUDE_DIR /usr/include )
252
                FIND_PACKAGE(FLTK)
253
	        ENDIF(NOT FLTK_INCLUDE_DIR)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
254
255
                
                IF(FLTK_FOUND)
256
257
258
259
260
261
		        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)
262

263
        ELSE(OTB_USE_EXTERNAL_FLTK)
264

265
266
267
268
269
270
271
                SET( FLTK_PLATFORM_DEPENDENT_LIBS "")
                IF(EXISTS "${OTB_BINARY_DIR}/Utilities/FLTK/FLTKConfig.cmake") 
                        INCLUDE(${OTB_BINARY_DIR}/Utilities/FLTK/FLTKConfig.cmake)
                ENDIF(EXISTS "${OTB_BINARY_DIR}/Utilities/FLTK/FLTKConfig.cmake") 
                #----------------------------------------------------------------
                # RESUME Alls VISU GUI libraries use by OTB in a single VARIABLE
                SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES} ")
272

273
        ENDIF(OTB_USE_EXTERNAL_FLTK)
274

275
276
ENDIF(OTB_USE_VISU_GUI)

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#-------------------------------
# CURL Library
#-------------------------------
OPTION(OTB_USE_CURL "Use curl library." OFF)
MARK_AS_ADVANCED(OTB_USE_CURL)
IF(OTB_USE_CURL)

#        INCLUDE(CheckIncludeFiles)
#        INCLUDE(CheckLibraryExists)
#        CHECK_INCLUDE_FILES("curl/curl.h" OTB_HAVE_CURL_HEADER)
#        CHECK_LIBRARY_EXISTS("curl" "curl_easy_init" "" OTB_HAVE_CURL_LIBRARY)
#        IF( NOT OTB_HAVE_CURL_HEADER )
#            MESSAGE("Cannot find CURL include directory. Please set CURL_INCLUDE_DIRS or SET OTB_USE_CURL OFF.")
#        ENDIF( NOT OTB_HAVE_CURL_HEADER)
#        IF( NOT OTB_HAVE_CURL_LIBRARY )
#            MESSAGE("Cannot find CURL include directory. Please set CURL_LIBRARY_DIRS or SET OTB_USE_CURL OFF.")
#        ENDIF( NOT OTB_HAVE_CURL_LIBRARY)

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

ENDIF(OTB_USE_CURL)

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

#FIND_LIBRARY(GDAL_LIBRARY_DIRS gdal PATHS $ENV{GDAL_LIBRARY_DIRS} ) 

FIND_PATH(GDAL_LIBRARY_DIRS gdal PATHS $ENV{GDAL_LIBRARY_DIRS} )
FIND_PATH(GDAL_INCLUDE_DIRS gdal.h $ENV{GDAL_INCLUDE_DIRS} /usr/include/gdal)
IF (NOT GDAL_LIBRARY_DIRS)
MESSAGE(FATAL_ERROR
         "Cannot find GDAL library directory. Please set GDAL_LIBRARY_DIRS.")
ENDIF (NOT GDAL_LIBRARY_DIRS)
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})
LINK_DIRECTORIES( ${GDAL_LIBRARY_DIRS} )

336

Thomas Feuvrier's avatar
Thomas Feuvrier committed
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#-------------------------------
# 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 (
  ${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)
405
IF(BUILD_TESTING)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
406
407
408
  ENABLE_TESTING()
  SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
  MARK_AS_ADVANCED(BUILDNAME)
409
ENDIF(BUILD_TESTING)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446


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




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(.)

#-----------------------------------------------------------------------------
# OTB build configuration options.
447
OPTION(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
448
449
SET(OTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})

450
# => Comment for OTB 2.6.0
Thomas Feuvrier's avatar
Thomas Feuvrier committed
451
452
# Options for building some of the most common core templates explicitly only
# once.  This has only been tested on gcc compilers.
453
454
455
456
457
#               OPTION(OTB_EXPLICIT_INSTANTIATION "BETA-Try to explicitly build some of the core templates explictitly rather than over and over again." OFF)
#               MARK_AS_ADVANCED(OTB_EXPLICIT_INSTANTIATION)
#               IF( OTB_EXPLICIT_INSTANTIATION )
#                ADD_DEFINITIONS(-DOTB_EXPLICIT_INSTANTIATION)
#               ENDIF( OTB_EXPLICIT_INSTANTIATION )
Thomas Feuvrier's avatar
Thomas Feuvrier committed
458
459
460

#-----------------------------------------------------------------------------
# Option for display all developpment message !!!
461
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
462
463
464
465
466
MARK_AS_ADVANCED(OTB_SHOW_ALL_MSG_DEBUG)
IF( OTB_SHOW_ALL_MSG_DEBUG )
 ADD_DEFINITIONS(-DOTB_ACTIVE_MSG_DEV_MACRO)
ENDIF( OTB_SHOW_ALL_MSG_DEBUG )

467
468
469
470
471
472
#-----------------------------------------------------------------------------
# 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)
473
MESSAGE("Warning: utilities compilation is disabled.")
474
475
476
477
LINK_DIRECTORIES("${OTB_BINARY_DIR}/bin")
ENDIF(OTB_DISABLE_UTILITIES_COMPILATION)


478
479
480
#-----------------------------------------------------------------------------
# Option to define streaming activation in applications
# Use by otbConfigure.h.in
481
SET(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING 8*4000*4000 CACHE STRING "Image size to activate using streaming for applications.")
482
MARK_AS_ADVANCED(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING)
483
SET(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING 8*4000*4000 CACHE STRING "Max size buffer for streaming.")
484
485
486
MARK_AS_ADVANCED(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING)


487
488
489
490
491
492
493
494

#-----------------------------------------------------------------------------
# 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
495
INCLUDE(${OTB_SOURCE_DIR}/Wrapping/otbWrapSetup.cmake)
496
497


Thomas Feuvrier's avatar
Thomas Feuvrier committed
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#-----------------------------------------------------------------------------
# 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)


IF(WIN32)
   IF(BUILD_SHARED_LIBS)
     SET(OTB_COMMON_BUILD_TYPE "SHARED")
   ELSE(BUILD_SHARED_LIBS)
     SET(OTB_COMMON_BUILD_TYPE "STATIC")
   ENDIF(BUILD_SHARED_LIBS)
   SET(BUILD_SHARED_LIBS OFF)
ENDIF(WIN32)

513

Thomas Feuvrier's avatar
Thomas Feuvrier committed
514
515
516
517
518
519
520
521
522
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)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
523

524
525
526
527
528
529
#-----------------------------------------------------------------------------
# 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
530
531

#SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "gdal dxf otbkml tinyXML otbgeotiff otbxtiff otbossim otbossimBase otbossimElevation otbossimFont otbossimKBool otbossimMatrix otbossimPlugin otbossimProjectionImaging otbossimSupportData otbossimVec otbossimVpfUtil")
532
533
534
535
536
537
SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "gdal;dxf;tinyXML;otbgeotiff;otbxtiff;otbossim" )
#otbossimBase otbossimElevation otbossimFont otbossimKBool otbossimMatrix otbossimPlugin otbossimProjectionImaging otbossimSupportData otbossimVec otbossimVpfUtil")

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

539
# Add EXPAT library
540
IF( OTB_USE_EXTERNAL_EXPAT )
541
        SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES  "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};expat")
542
ELSE( OTB_USE_EXTERNAL_EXPAT  )
543
        SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES  "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};otbexpat")
544
ENDIF( OTB_USE_EXTERNAL_EXPAT )
545

546
547
548
549
550
# Add Open Jpeg library
IF( OTB_COMPILE_JPEG2000 )
     SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};otbopenjpeg") 
ENDIF( OTB_COMPILE_JPEG2000 )

551
552

# Add VISU libraries
553
554
555
#IF(OTB_USE_VISU_GUI)
#        SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES  "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES} ${OTB_VISU_GUI_LIBRARIES}")
#ENDIF(OTB_USE_VISU_GUI)
556
557

# => Create OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES
558
SET(OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES "otb6S;otbgalib;InsightJournal;otbsvm")
559
560
561
562
563


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

564

565
#-----------------------------------------------------------------------------
566
OPTION(BUILD_EXAMPLES "Build the Examples directory." OFF)
567

Thomas Feuvrier's avatar
Thomas Feuvrier committed
568
569
570

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

Thomas Feuvrier's avatar
Thomas Feuvrier committed
572
573
SUBDIRS(Utilities Code)

574
575
SUBDIRS(Wrapping)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
576
577
578
579
580
581
582
583
584
IF (BUILD_EXAMPLES)
  SUBDIRS(Examples)
ENDIF (BUILD_EXAMPLES)

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

#-----------------------------------------------------------------------------
585
# => Comment for OTB 2.6.0: simplification : copy ITK values
Thomas Feuvrier's avatar
Thomas Feuvrier committed
586
# OTB requires special compiler flags on some platforms.
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
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(CMAKE_COMPILER_IS_GNUCXX)
#            SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -ftemplate-depth-50")
#            IF(APPLE)
#              SET(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} -no-cpp-precomp")
#              SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -no-cpp-precomp")
#              SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -Wno-long-double")
#            ENDIF(APPLE)
#          ENDIF(CMAKE_COMPILER_IS_GNUCXX)

#          IF(UNIX)
#            IF(NOT CMAKE_COMPILER_IS_GNUCXX)
#              INCLUDE(${OTB_SOURCE_DIR}/CMake/TestNO_ICC_IDYNAMIC_NEEDED.cmake)
#              TESTNO_ICC_IDYNAMIC_NEEDED(NO_ICC_IDYNAMIC_NEEDED ${OTB_SOURCE_DIR}/CMake )
#              IF(NO_ICC_IDYNAMIC_NEEDED)
#                SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS}")
#              ELSE(NO_ICC_IDYNAMIC_NEEDED)
#                SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -i_dynamic")
#              ENDIF(NO_ICC_IDYNAMIC_NEEDED)
#            ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
#          ENDIF(UNIX)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
611
612

# Force the use of ansi cxx flags (i.e. -LANG:std on sgi )
613
614
615
616
617
618
619
620
621
622
623
624
625
#          IF("x${CMAKE_ANSI_CXXFLAGS}" MATCHES "^x.*[^ ]")
#            SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
#          ENDIF("x${CMAKE_ANSI_CXXFLAGS}" MATCHES "^x.*[^ ]")
#          IF("x${CMAKE_ANSI_CFLAGS}" MATCHES "^x.*[^ ]")
#            SET(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
#          ENDIF("x${CMAKE_ANSI_CFLAGS}" MATCHES "^x.*[^ ]")

#          IF(CMAKE_SYSTEM MATCHES "IRIX.*")
#            IF(NOT CMAKE_COMPILER_IS_GNUCXX)
#              SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -woff 15,84,1110,1209,1424,1468,3102,3210,3439  -no_auto_include -ptused -no_prelink")
#              SET(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS}  -Wl,-woff15")
#            ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
#          ENDIF(CMAKE_SYSTEM MATCHES "IRIX.*")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
626
627
628
629
630
631
632

IF(MINGW)
  LINK_LIBRARIES(gdi32)
ENDIF(MINGW)

# for the gnu compiler a -D_PTHREADS is needed on sun
# for the native compiler a -mt flag is needed on the sun
633
634
635
636
637
638
639
640
641
642
643
644
645
646
#          IF(CMAKE_USE_PTHREADS)
#            IF(CMAKE_SYSTEM MATCHES "SunOS.*")
#              IF(CMAKE_COMPILER_IS_GNUCXX)
#                SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -D_PTHREADS")
#              ELSE(CMAKE_COMPILER_IS_GNUCXX)
#                SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -mt")
#                SET(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} -mt")
#              ENDIF(CMAKE_COMPILER_IS_GNUCXX)
#            ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
#          ENDIF(CMAKE_USE_PTHREADS)

#          IF(WIN32)
#            SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -DNOMINMAX")
#          ENDIF(WIN32)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
647

648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
#-----------------------------------------------------------------------------
# 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)
#-----------------------------------------------------------------------------
# mingw thread support
668
669
670
671
672
#          IF(MINGW)
#            SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -mthreads")
#            SET(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} -mthreads")
#            SET(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} -mthreads")
#          ENDIF(MINGW)
673
674


Thomas Feuvrier's avatar
Thomas Feuvrier committed
675
#-----------------------------------------------------------------------------
676
# => Comment for OTB 2.6.0
Thomas Feuvrier's avatar
Thomas Feuvrier committed
677
678
679
#
# See if compiler preprocessor has the __FUNCTION__ directive used by itkExceptionMacro
#
680
681
#               INCLUDE(${OTB_SOURCE_DIR}/CMake/CheckCPPDirective.cmake)
#               CHECK_CPP_DIRECTIVE_EXISTS(__FUNCTION__ ITK_CPP_FUNCTION)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
682
683
684


#-----------------------------------------------------------------------------
685
# => Comment for OTB 2.6.0
Thomas Feuvrier's avatar
Thomas Feuvrier committed
686
687
# Find platform-specific differences in the handling of IEEE floating point 
# special values.
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
#          INCLUDE(${OTB_SOURCE_DIR}/CMake/CheckBigBitfield.cmake)
#          CHECK_BIG_BITFIELD(BIGBITFIELD_VALUE ${OTB_SOURCE_DIR}/CMake)
#          IF(BIGBITFIELD_VALUE)
#             SET(BIGBITFIELD 1 CACHE INTERNAL "System handles bit-fields larger than 32 bits.")
#          ELSE(BIGBITFIELD_VALUE)
#             SET(BIGBITFIELD 0 CACHE INTERNAL "System handles bit-fields larger than 32 bits.")
#          ENDIF(BIGBITFIELD_VALUE)

# => Comment for OTB 2.6.0
#          INCLUDE(${OTB_SOURCE_DIR}/CMake/TestQnanhibit.cmake)
#          TEST_QNANHIBIT(QNANHIBIT_VALUE ${OTB_SOURCE_DIR}/CMake)
#          IF(QNANHIBIT_VALUE)
#             SET(QNANHIBIT 1 CACHE INTERNAL "The 22nd bit of 32-bit floating-point quiet NaN.")
#          ELSE(QNANHIBIT_VALUE)
#             SET(QNANHIBIT 0 CACHE INTERNAL "The 22nd bit of 32-bit floating-point quiet NaN.")
#          ENDIF(QNANHIBIT_VALUE)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
705
706
707
708
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
709
710
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
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
768
769
770
771
772
773
774
775
776
777
# => Comment for OTB 2.6.0
#          IF(OTB_SIZEOF___INT64)
#            IF("OTB_TYPE_SAME_LONG_AND___INT64" MATCHES "^OTB_TYPE_SAME_LONG_AND___INT64$")
#              MESSAGE(STATUS "Checking whether long and __int64 are the same type")
#              TRY_COMPILE(OTB_TYPE_SAME_LONG_AND___INT64
#                ${OTB_BINARY_DIR}/CMakeTmp
#                ${OTB_SOURCE_DIR}/CMake/otbTestCompareTypes.cxx
#                COMPILE_DEFINITIONS
#                -DOTB_TEST_COMPARE_TYPE_1=long
#                -DOTB_TEST_COMPARE_TYPE_2=__int64
#                OUTPUT_VARIABLE OUTPUT)
#              IF(OTB_TYPE_SAME_LONG_AND___INT64)
#                MESSAGE(STATUS "Checking whether long and __int64 are the same type -- yes")
#                SET(OTB_TYPE_SAME_LONG_AND___INT64 1 CACHE INTERNAL "Whether long and __int64 are the same type")
#              ELSE(OTB_TYPE_SAME_LONG_AND___INT64)
#                MESSAGE(STATUS "Checking whether long and __int64 are the same type -- no")
#                SET(OTB_TYPE_SAME_LONG_AND___INT64 0 CACHE INTERNAL "Whether long and __int64 are the same type")
#                WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
#                  "Determining whether long and __int64 are the same type "
#                  "failed with the following output:\n"
#                  "${OUTPUT}\n" APPEND)
#              ENDIF(OTB_TYPE_SAME_LONG_AND___INT64)
#            ENDIF("OTB_TYPE_SAME_LONG_AND___INT64" MATCHES "^OTB_TYPE_SAME_LONG_AND___INT64$")
#          ENDIF(OTB_SIZEOF___INT64)
#          IF(OTB_SIZEOF_LONG_LONG)
#            CONFIGURE_FILE(${OTB_SOURCE_DIR}/CMake/otbTestStreamLongLong.cxx.in
#              ${OTB_BINARY_DIR}/otbTestStreamLongLong.cxx @ONLY IMMEDIATE)
#            IF("OTB_OSTREAM_SUPPORTS_LONG_LONG" MATCHES "^OTB_OSTREAM_SUPPORTS_LONG_LONG$")
#              MESSAGE(STATUS "Checking if ostream supports long long")
#              TRY_COMPILE(OTB_OSTREAM_SUPPORTS_LONG_LONG
#                ${OTB_BINARY_DIR}
#                ${OTB_BINARY_DIR}/otbTestStreamLongLong.cxx
#                COMPILE_DEFINITIONS -DOTB_TEST_OSTREAM_LONG_LONG
#                OUTPUT_VARIABLE OUTPUT)
#              IF(OTB_OSTREAM_SUPPORTS_LONG_LONG)
#                MESSAGE(STATUS "Checking if ostream supports long long -- yes")
#                SET(OTB_OSTREAM_SUPPORTS_LONG_LONG 1 CACHE INTERNAL "Whether ostream supports long long")
#              ELSE(OTB_OSTREAM_SUPPORTS_LONG_LONG)
#                MESSAGE(STATUS "Checking if ostream supports long long -- no")
#                SET(OTB_OSTREAM_SUPPORTS_LONG_LONG 0 CACHE INTERNAL "Whether ostream supports long long")
#                WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
#                  "Determining if ostream supports long long "
#                  "failed with the following output:\n"
#                  "${OUTPUT}\n" APPEND)
#              ENDIF(OTB_OSTREAM_SUPPORTS_LONG_LONG)
#            ENDIF("OTB_OSTREAM_SUPPORTS_LONG_LONG" MATCHES "^OTB_OSTREAM_SUPPORTS_LONG_LONG$")
#            IF("OTB_ISTREAM_SUPPORTS_LONG_LONG" MATCHES "^OTB_ISTREAM_SUPPORTS_LONG_LONG$")
#              MESSAGE(STATUS "Checking if istream supports long long")
#              TRY_COMPILE(OTB_ISTREAM_SUPPORTS_LONG_LONG
#                ${OTB_BINARY_DIR}
#                ${OTB_BINARY_DIR}/otbTestStreamLongLong.cxx
#                COMPILE_DEFINITIONS -DOTB_TEST_ISTREAM_LONG_LONG
#                OUTPUT_VARIABLE OUTPUT)
#              IF(OTB_ISTREAM_SUPPORTS_LONG_LONG)
#                MESSAGE(STATUS "Checking if istream supports long long -- yes")
#                SET(OTB_ISTREAM_SUPPORTS_LONG_LONG 1 CACHE INTERNAL "Whether istream supports long long")
#              ELSE(OTB_ISTREAM_SUPPORTS_LONG_LONG)
#                MESSAGE(STATUS "Checking if istream supports long long -- no")
#                SET(OTB_ISTREAM_SUPPORTS_LONG_LONG 0 CACHE INTERNAL "Whether istream supports long long")
#                WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
#                  "Determining if istream supports long long "
#                  "failed with the following output:\n"
#                  "${OUTPUT}\n" APPEND)
#              ENDIF(OTB_ISTREAM_SUPPORTS_LONG_LONG)
#            ENDIF("OTB_ISTREAM_SUPPORTS_LONG_LONG" MATCHES "^OTB_ISTREAM_SUPPORTS_LONG_LONG$")
#          ENDIF(OTB_SIZEOF_LONG_LONG)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849


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


#-----------------------------------------------------------------------------
# Configure files with settings for use by the build.
CONFIGURE_FILE(${OTB_SOURCE_DIR}/otbConfigure.h.in 
               ${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}")

#-----------------------------------------------------------------------------
850
# => Comment for OTB 2.6.0
Thomas Feuvrier's avatar
Thomas Feuvrier committed
851
852
853
# The frename-registers option does not work due to a bug in the gnu compiler.
# It must be removed or data errors will be produced and incorrect results
# will be produced.  This is first documented in the gcc4 man page.
854
855
856
857
858
859
860
861
862
863
864
865
866
#          IF(CMAKE_COMPILER_IS_GNUCXX)
#            SET(ALL_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
#            SEPARATE_ARGUMENTS(ALL_FLAGS)
#            FOREACH(COMP_OPTION ${ALL_FLAGS})
#              #  MESSAGE("${COMP_OPTION} being checked.")
#              IF("${COMP_OPTION}" STREQUAL "-frename-registers")
#                MESSAGE(FATAL_ERROR "-frename-registers causes runtime bugs.  It must be removed from your compilation options.")
#              ENDIF("${COMP_OPTION}" STREQUAL "-frename-registers")
#              IF("${COMP_OPTION}" STREQUAL "-ffloat-store")
#                MESSAGE(FATAL_ERROR "-ffloat-store causes runtime bugs on gcc 3.2.3 (appearently not on gcc 3.4.3, but the exact criteria is not known).  It must be removed from your compilation options.")
#              ENDIF("${COMP_OPTION}" STREQUAL "-ffloat-store")
#            ENDFOREACH(COMP_OPTION)
#          ENDIF(CMAKE_COMPILER_IS_GNUCXX)