CMakeLists.txt 45.6 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

PROJECT(OTB)

11 12 13 14 15
# Path to additional CMake modules
SET(CMAKE_MODULE_PATH
    ${CMAKE_SOURCE_DIR}/CMake
    ${CMAKE_MODULE_PATH})

Thomas Feuvrier's avatar
Thomas Feuvrier committed
16 17
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$")
18
INCLUDE(CMakeDependentOption)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

# 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)
44 45 46 47
# __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
48 49

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

58 59 60 61
#-----------------------------------------------------------------------------
# OTB option to access large file (> 4Go).
ADD_DEFINITIONS(
	-D_LARGEFILE_SOURCE
62
	-D_FILE_OFFSET_BITS=64
63
	-D_LARGEFILE64_SOURCE
64
	-D_LARGE_FILES
65
	)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
66 67 68

#-----------------------------------------------------------------------------
# OTB version number.  An even minor number corresponds to releases.
69
SET(OTB_VERSION_MAJOR "3")
70
SET(OTB_VERSION_MINOR "2")
Julien Michel's avatar
Julien Michel committed
71
SET(OTB_VERSION_PATCH "1")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
72

73

Thomas Feuvrier's avatar
Thomas Feuvrier committed
74 75 76 77
# 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}")

78
OPTION(BUILD_TESTING "Build testing." OFF)
79

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

91 92 93
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.
94
  SET(OTB_LIBRARY_PROPERTIES
95 96 97 98 99
      VERSION   "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH}"
      SOVERSION "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}"
     )
ENDIF(NOT OTB_NO_LIBRARY_VERSION)

100 101
SET(OTB_BUILD_PEDANTIC OFF CACHE BOOL
    "Choose compilation in pedantic or relaxed mode")
102

103 104 105 106
IF(WIN32)
  IF (MSVC)
    IF(OTB_BUILD_PEDANTIC)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
107
    ENDIF(OTB_BUILD_PEDANTIC)
108 109 110 111

    IF (MSVC80)
      ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
      ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNING)
112 113 114
    ENDIF(MSVC80)
  ENDIF(MSVC)
ELSE(WIN32)
115 116 117
  IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
    IF(OTB_BUILD_PEDANTIC)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
118 119
    ENDIF(OTB_BUILD_PEDANTIC)
  ENDIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
120
ENDIF(WIN32)
121 122 123
#-----------------------------------------------------------------------------

# Use the openjpeg library.
124
OPTION(OTB_USE_JPEG2000 "Use to support jpeg2000 image file format." ON)
125

Thomas Feuvrier's avatar
Thomas Feuvrier committed
126
#-----------------------------------------------------------------------------
127

128 129 130
# 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)
131

132
# FIND EXTERNAL LIBRAIRIES USE
Thomas Feuvrier's avatar
Thomas Feuvrier committed
133

134 135 136 137
#-------------------------------
# EXPAT Library
#-------------------------------

138 139 140 141 142 143 144
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)

145
MARK_AS_ADVANCED(OTB_USE_EXTERNAL_EXPAT)
146

147 148 149
IF(OTB_USE_EXTERNAL_EXPAT)
    FIND_PACKAGE(EXPAT)
    IF(EXPAT_FOUND)
150 151 152
        # Control expat compatibility
        INCLUDE_DIRECTORIES(BEFORE ${EXPAT_INCLUDE_DIR})
        LINK_DIRECTORIES( ${EXPAT_LIBRARY} )
153 154 155 156 157
    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)
158 159 160
        ADD_DEFINITIONS(-DOTB_USE_INTERNAL_EXPAT)
        INCLUDE_DIRECTORIES(BEFORE "${OTB_SOURCE_DIR}/Utilities/otbexpat")
        INCLUDE_DIRECTORIES(BEFORE "${OTB_BINARY_DIR}/Utilities/otbexpat")
161 162 163
	IF(NOT BUILD_SHARED_LIBS)
        	ADD_DEFINITIONS(-DXML_STATIC)
        ENDIF(NOT BUILD_SHARED_LIBS)
164
ENDIF(OTB_USE_EXTERNAL_EXPAT)
165

166 167 168 169 170 171 172 173
#-------------------------------
# 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)
174 175 176 177 178 179 180 181 182
        # 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}")

183 184 185 186 187
        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)
188 189 190 191
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)
192 193 194 195
ENDIF(OTB_USE_EXTERNAL_ITK)


# JPEG2000 specification control
OTB Bot's avatar
OTB Bot committed
196
SET(OTB_COMPILE_JPEG2000 0)
197 198 199 200 201 202 203
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
204
        MESSAGE(STATUS "WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
205 206 207
        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
208
        MESSAGE(STATUS "WARNING: For Visual Studio 7, jpeg2000 support is disabled.")
209 210
        SET(OTB_COMPILE_JPEG2000 0)
  ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio 7 .NET 2003$")
211
  IF(CYGWIN)
Julien Michel's avatar
Julien Michel committed
212
        MESSAGE(STATUS "WARNING: For cygwin, jpeg2000 support is disabled.")
213 214 215
        SET(OTB_COMPILE_JPEG2000 0)
  ENDIF(CYGWIN)

216
ENDIF( OTB_USE_JPEG2000 )
217
# Check jpeg2000 support
218 219
IF(OTB_COMPILE_JPEG2000)
  ADD_DEFINITIONS(-DOTB_COMPILE_JPEG2000 -DUSE_OPJ_DEPRECATED)
Thomas Feuvrier's avatar
Modif  
Thomas Feuvrier committed
220 221 222
  IF(NOT BUILD_SHARED_LIBS)
        ADD_DEFINITIONS(-DOPJ_STATIC)
  ENDIF(NOT BUILD_SHARED_LIBS)
223 224
ENDIF(OTB_COMPILE_JPEG2000)

225 226 227
#-----------------------------------------------------------------------------
# Option for OpenThreads (necessary because used by the new version of OSSIM library
# Find OpenThread library
228
IF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
229
        FIND_PACKAGE(OpenThreads)
230
ELSE(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
231
        INCLUDE(${OTB_SOURCE_DIR}/CMake/FindOpenThreads.cmake)
232
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
233

234
SET(OTB_USE_EXTERNAL_OPENTHREADS ON CACHE INTERNAL "")
235 236 237 238 239
IF(OPENTHREADS_FOUND)
        INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
        LINK_DIRECTORIES( ${OPENTHREADS_LIBRARY} )
ELSE(OPENTHREADS_FOUND)
        ADD_DEFINITIONS(-DOTB_USE_INTERNAL_OPENTHREADS)
240
        SET(OTB_USE_EXTERNAL_OPENTHREADS OFF)
241 242 243
        SET(OPENTHREADS_INCLUDE_DIR "${OTB_SOURCE_DIR}/Utilities/otbopenthreads/OpenThreads/include")
        SET(OPENTHREADS_LIBRARY "OpenThreads" )
        INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
244 245 246
	IF(NOT BUILD_SHARED_LIBS)
         ADD_DEFINITIONS(-DOT_LIBRARY_STATIC)
        ENDIF(NOT BUILD_SHARED_LIBS)
247
ENDIF(OPENTHREADS_FOUND)
248

249 250 251 252
IF(NOT BUILD_SHARED_LIBS)
  ADD_DEFINITIONS(-DOSSIM_STATIC)
ENDIF(NOT BUILD_SHARED_LIBS)

253

Thomas Feuvrier's avatar
Thomas Feuvrier committed
254 255
#-----------------------------------------------------------------------------
# Option for generate Visu tools !!!
256
OPTION(OTB_USE_VISU_GUI "Generate Gui/Visu tools directory. If ON, find OpenGL and FLTK packages." ON)
257
MARK_AS_ADVANCED(OTB_USE_VISU_GUI)
258

OTB Bot's avatar
OTB Bot committed
259
SET(OTB_GLU_INCLUDE_PATH "")
260
IF(OTB_USE_VISU_GUI)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
261 262

        #-------------------------------
263
        # OpenGL Library
Thomas Feuvrier's avatar
Thomas Feuvrier committed
264 265
        #-------------------------------
        FIND_PACKAGE(OpenGL)
266

Thomas Feuvrier's avatar
Thomas Feuvrier committed
267
        IF( NOT OPENGL_FOUND )
268 269
                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 )
Thomas Feuvrier's avatar
Thomas Feuvrier committed
270
        IF( NOT OPENGL_GLU_FOUND )
271
                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 !")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
272 273 274 275 276
        ENDIF( NOT OPENGL_GLU_FOUND )

        IF(OPENGL_INCLUDE_DIR)
                INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
        ENDIF(OPENGL_INCLUDE_DIR)
277 278 279 280

	#-------------------------------
        # Display images using textures using video card acceleration
        #-------------------------------
281
	OPTION(OTB_GL_USE_ACCEL "Use video card acceleration." OFF)
282
	MARK_AS_ADVANCED(OTB_GL_USE_ACCEL)
283

Thomas Feuvrier's avatar
Thomas Feuvrier committed
284
        #-------------------------------
Thomas Feuvrier's avatar
Thomas Feuvrier committed
285
        # FLTK Library
Thomas Feuvrier's avatar
Thomas Feuvrier committed
286
        #-------------------------------
287 288 289
        
        #OPTION(OTB_USE_EXTERNAL_FLTK "Use an outside build of FLTK." OFF)
        
290
        FIND_PACKAGE(FLTK)
291 292

	# If an external fltk is found, do not provide the internal fltk choice
293 294 295 296 297
	IF(FLTK_FOUND)
       OPTION(OTB_USE_EXTERNAL_FLTK "Use an outside build of FLTK." ON)
	ELSE(FLTK_FOUND)
	   OPTION(OTB_USE_EXTERNAL_FLTK "Use an outside build of FLTK." OFF)
	ENDIF(FLTK_FOUND)
298 299 300 301 302 303
                         
#        IF(FLTK_FOUND)
#           SET(OTB_USE_EXTERNAL_FLTK ON)
#        ELSE(FLTK_FOUND)
#           SET(OTB_USE_EXTERNAL_FLTK OFF)
#        ENDIF(FLTK_FOUND)
304

305
        # Option for internal/external FLTK
Thomas Feuvrier's avatar
MRG  
Thomas Feuvrier committed
306
        MARK_AS_ADVANCED(OTB_USE_EXTERNAL_FLTK)
307

308 309
        IF(OTB_USE_EXTERNAL_FLTK)

310
                # Mingw Option doesn't exist in the FindFLTK.cmake default configuration file in CMake installationj directory.
311 312 313 314 315
                # 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)
316

Thomas Feuvrier's avatar
Thomas Feuvrier committed
317
                IF(FLTK_FOUND)
318
                    INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIR})
319
                ELSE(FLTK_FOUND)
320
                    MESSAGE(FATAL_ERROR
321 322
	                        "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)
323

324
        ELSE(OTB_USE_EXTERNAL_FLTK)
325 326 327
                SET(FLTK_INCLUDE_DIR "")
                SET(FLTK_LIBRARIES "")
                
328
                SET( FLTK_PLATFORM_DEPENDENT_LIBS "")
329
                INCLUDE(${OTB_BINARY_DIR}/Utilities/FLTK/FLTKConfig.cmake)
330

331
        ENDIF(OTB_USE_EXTERNAL_FLTK)
332

333 334
        SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES} ")
        SET(FLTK_FLUID_EXECUTABLE ${FLUID_COMMAND})
335 336
ENDIF(OTB_USE_VISU_GUI)

337 338 339
#-------------------------------
# CURL Library
#-------------------------------
340 341 342 343 344 345 346
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)

347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
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)

364 365 366
        # Add compiler option
        ADD_DEFINITIONS(-DOTB_USE_CURL)

367 368 369 370
        INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})

ENDIF(OTB_USE_CURL)

371 372 373
#-------------------------------
# Mapnik Library
#-------------------------------
374
OPTION(OTB_USE_MAPNIK "Use mapnik library." OFF)
375 376 377 378 379 380 381 382 383 384
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)

385 386 387 388 389 390 391
        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)

392 393 394 395 396 397 398
        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)

399
        # Add compiler option
400 401 402 403
        ADD_DEFINITIONS(-DOTB_USE_MAPNIK)

        INCLUDE_DIRECTORIES(${MAPNIK_INCLUDE_DIR})

404

405 406
ENDIF(OTB_USE_MAPNIK)

Jordi Inglada's avatar
Jordi Inglada committed
407 408 409 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
#-------------------------------
# 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)

436

Jordi Inglada's avatar
Jordi Inglada committed
437 438 439 440 441 442 443
# Add compiler option
        ADD_DEFINITIONS(-DOTB_USE_PQXX)

        INCLUDE_DIRECTORIES(${PQXX_INCLUDE_DIR})

ENDIF(OTB_USE_PQXX)

444

445 446 447
#-------------------------------
# Boost Library
#-------------------------------
448 449 450 451 452 453
FIND_PACKAGE(Boost)
IF(Boost_FOUND)
  OPTION(OTB_USE_EXTERNAL_BOOST "Use an outside build of Boost." ON)
ELSE(Boost_FOUND)
  OPTION(OTB_USE_EXTERNAL_BOOST "Use an outside build of Boost." OFF)
ENDIF(Boost_FOUND)
454 455 456
# Option for internal/external BOOST
MARK_AS_ADVANCED(OTB_USE_EXTERNAL_BOOST)

457 458 459 460 461 462
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)

463 464
IF(OTB_USE_EXTERNAL_BOOST)
  FIND_PACKAGE(Boost)
465 466 467 468

  TRY_COMPILE(BOOST_IS_COMPLETE
  ${CMAKE_CURRENT_BINARY_DIR}/CMake
  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/otbTestCompileBoost.cxx
469
  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${Boost_INCLUDE_DIR}"
470 471
  OUTPUT_VARIABLE OUTPUT)
  IF(BOOST_IS_COMPLETE)
472
    MESSAGE(STATUS "Testing external Boost library    -- yes")
473
  ELSE(BOOST_IS_COMPLETE)
474
    MESSAGE(STATUS "Testing external Boost library    -- no")
475
    MESSAGE(STATUS "Force the OTB_USE_EXTERNAL_BOOST value to OFF.")
476
    SET(OTB_USE_EXTERNAL_BOOST OFF CACHE BOOL  "Use an outside build of Boost." FORCE )
477 478
  ENDIF(BOOST_IS_COMPLETE)

479 480 481
  INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
ENDIF(OTB_USE_EXTERNAL_BOOST)

482 483 484 485
#-------------------------------
# GDAL Library
#-------------------------------

486 487
# Option for internal/external GDAL
OPTION(OTB_USE_EXTERNAL_GDAL "Use an outside build of GDAL. (OFF is EXPERIMENTAL)" ON)
488 489 490
MARK_AS_ADVANCED(OTB_USE_EXTERNAL_GDAL)

IF(OTB_USE_EXTERNAL_GDAL)
491
  FIND_PACKAGE(GDAL)
492

493 494 495 496
  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)
497

498 499 500 501
  IF (NOT GDAL_INCLUDE_DIR)
  MESSAGE(FATAL_ERROR
           "Cannot find GDAL include directory. Please set GDAL_INCLUDE_DIR.")
  ENDIF (NOT GDAL_INCLUDE_DIR)
502

503
  INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIR})
504 505 506 507 508 509 510 511

  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 geotiff headers
512
  FIND_PATH(GEOTIFF_INCLUDE_DIRS geotiff.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include/geotiff)
513 514 515 516 517 518 519
  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
520
  FIND_PATH(TIFF_INCLUDE_DIRS tiffio.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
521 522 523 524 525 526 527
  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
528
  FIND_PATH(JPEG_INCLUDE_DIRS jpeglib.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
529 530 531 532 533 534 535
  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
536
  FIND_PATH(OGR_INCLUDE_DIRS ogrsf_frmts.h  $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
537 538 539 540 541 542 543 544 545 546
  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
547
  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${TIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
  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
565
  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GEOTIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582
  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
583
  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${JPEG_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
584 585 586 587 588 589 590 591 592 593 594 595 596
  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)

Emmanuel Christophe's avatar
Emmanuel Christophe committed
597
  # Check if ${GDAL_LIBRARY} has ogr library
598 599 600
  TRY_COMPILE(GDAL_HAS_OGR
  ${CMAKE_CURRENT_BINARY_DIR}/CMake
  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasOGR.cxx
601
  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${OGR_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
  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)
617

618
#Experimental
619 620 621
OPTION(OTB_USE_GETTEXT "Get Text Library." ON)

IF(OTB_USE_GETTEXT)
622 623
FIND_PACKAGE(Gettext)
IF(GETTEXT_FOUND)
624 625 626 627
  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)
628 629 630

  IF(GETTEXT_LIBRARY)
      SET(OTB_I18N 1)
631 632
      MESSAGE(STATUS
              "Gettext found, configuring internationalization")
633
      SET(OTB_LANG $ENV{LANG} CACHE STRING "OTB internationalization (Experimental)")#might want to get the Locale from the system here
634
      IF(NOT OTB_LANG)
635
        SET(OTB_LANG "en_EN.UTF-8" CACHE STRING "OTB internationalization (Experimental)" FORCE)
636
      ENDIF(NOT OTB_LANG)
637 638 639 640 641 642 643 644 645 646 647 648
      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)

649 650 651 652 653
ELSE(GETTEXT_FOUND)
  SET(OTB_I18N 0)
  MESSAGE(STATUS
              "Gettext not found, internationalization will not be available")
ENDIF(GETTEXT_FOUND)
654
ENDIF(OTB_USE_GETTEXT)
655

Thomas Feuvrier's avatar
Thomas Feuvrier committed
656 657 658 659
#-------------------------------
# End connections whith external libraries
#-------------------------------

660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 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
#-----------------------------------------------------------------------------
# Installation vars.
# OTB_INSTALL_BIN_DIR          - binary dir (executables)
# OTB_INSTALL_LIB_DIR          - library dir (libs)
# OTB_INSTALL_DATA_DIR         - share dir (say, examples, data, etc)
# OTB_INSTALL_INCLUDE_DIR      - include dir (headers)
# OTB_INSTALL_PACKAGE_DIR      - package/export configuration files
# OTB_INSTALL_NO_DEVELOPMENT   - do not install development files
# OTB_INSTALL_NO_RUNTIME       - do not install runtime files
# OTB_INSTALL_NO_DOCUMENTATION - do not install documentation files

IF(NOT OTB_INSTALL_BIN_DIR)
  SET(OTB_INSTALL_BIN_DIR "/bin")
ENDIF(NOT OTB_INSTALL_BIN_DIR)

IF(NOT OTB_INSTALL_LIB_DIR)
  SET(OTB_INSTALL_LIB_DIR "/lib/otb")
ENDIF(NOT OTB_INSTALL_LIB_DIR)

IF(NOT OTB_INSTALL_DATA_DIR)
  SET(OTB_INSTALL_DATA_DIR "/share/otb")
ENDIF(NOT OTB_INSTALL_DATA_DIR)

IF(NOT OTB_INSTALL_INCLUDE_DIR)
  SET(OTB_INSTALL_INCLUDE_DIR "/include/otb")
ENDIF(NOT OTB_INSTALL_INCLUDE_DIR)

IF(NOT OTB_INSTALL_PACKAGE_DIR)
  SET(OTB_INSTALL_PACKAGE_DIR ${OTB_INSTALL_LIB_DIR}
    CACHE INTERNAL "")
ENDIF(NOT OTB_INSTALL_PACKAGE_DIR)

IF(NOT OTB_INSTALL_NO_DEVELOPMENT)
  SET(OTB_INSTALL_NO_DEVELOPMENT 0)
ENDIF(NOT OTB_INSTALL_NO_DEVELOPMENT)

IF(NOT OTB_INSTALL_NO_RUNTIME)
  SET(OTB_INSTALL_NO_RUNTIME 0)
ENDIF(NOT OTB_INSTALL_NO_RUNTIME)

IF(NOT OTB_INSTALL_NO_DOCUMENTATION)
  SET(OTB_INSTALL_NO_DOCUMENTATION 0)
ENDIF(NOT OTB_INSTALL_NO_DOCUMENTATION)

SET(OTB_INSTALL_NO_LIBRARIES)
IF(OTB_BUILD_SHARED_LIBS)
  IF(OTB_INSTALL_NO_RUNTIME AND OTB_INSTALL_NO_DEVELOPMENT)
    SET(OTB_INSTALL_NO_LIBRARIES 1)
  ENDIF(OTB_INSTALL_NO_RUNTIME AND OTB_INSTALL_NO_DEVELOPMENT)
ELSE(OTB_BUILD_SHARED_LIBS)
  IF(OTB_INSTALL_NO_DEVELOPMENT)
    SET(OTB_INSTALL_NO_LIBRARIES 1)
  ENDIF(OTB_INSTALL_NO_DEVELOPMENT)
ENDIF(OTB_BUILD_SHARED_LIBS)

# Because INSTALL_* commands require a leading / and because INSTALL (cmake 2.4
# and newer) requires no leading / to install under INSTALL_PREFIX, we
# are stripping the leading /. In the future, there should be no leading
# / in any install directory variables
STRING(REGEX REPLACE "^/" "" OTB_INSTALL_LIB_DIR_CM24 "${OTB_INSTALL_LIB_DIR}")
STRING(REGEX REPLACE "^/" "" OTB_INSTALL_BIN_DIR_CM24 "${OTB_INSTALL_BIN_DIR}")
STRING(REGEX REPLACE "^/" "" OTB_INSTALL_INCLUDE_DIR_CM24 "${OTB_INSTALL_INCLUDE_DIR}")
STRING(REGEX REPLACE "^/" "" OTB_INSTALL_PACKAGE_DIR_CM24 "${OTB_INSTALL_PACKAGE_DIR}")
STRING(REGEX REPLACE "^/" "" OTB_INSTALL_DOXYGEN_DIR_CM24 "${OTB_INSTALL_DOXYGEN_DIR}")
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}")


Thomas Feuvrier's avatar
Thomas Feuvrier committed
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761
# 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)
762
    FIND_FILE(ITK_FLTK_RESOURCE mac.r ${FLTK_DIR}/include/FL)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790
    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 (
791
  ${OTB_BINARY_DIR}
Thomas Feuvrier's avatar
Thomas Feuvrier committed
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
  ${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)
808
ENABLE_TESTING()
809
IF(BUILD_TESTING)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
810 811
  SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
  MARK_AS_ADVANCED(BUILDNAME)
812
ENDIF(BUILD_TESTING)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
813 814 815 816 817 818


#-----------------------------------------------------------------------------
# Output directories.


819 820 821
#       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)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
822 823 824 825 826 827 828
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.
829
   SET(OTB_LIBRARY_PROPERTIES
Thomas Feuvrier's avatar
Thomas Feuvrier committed
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
       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 !!!
850
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
851
MARK_AS_ADVANCED(OTB_SHOW_ALL_MSG_DEBUG)
852 853 854
# 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
855

856 857 858 859
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)
860
    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.")
861 862 863 864 865
    MARK_AS_ADVANCED(OTB_FULL_WARNING_LIST_PARAMETERS)
  ENDIF(CMAKE_COMPILER_IS_GNUCXX)

ENDIF(OTB_COMPILE_WITH_FULL_WARNING)

866 867 868 869 870 871
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)
IF(OTB_CPP_CHECK_SOURCE_FILE)
  FIND_PROGRAM(OTB_CPP_CHECK_PROG "")
ENDIF(OTB_CPP_CHECK_SOURCE_FILE)

872
MACRO(OTB_ADD_EXECUTABLE name sources libraries)
873 874 875 876 877 878 879 880 881 882
#  MESSAGE(STATUS "name: ${name}")
#  MESSAGE(STATUS "sources: ${sources}")
#  MESSAGE(STATUS "libraries: ${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}
883
                            PRE_BUILD
884 885 886 887 888 889 890
                            COMMAND ${OTB_CPP_CHECK_PROG}
                            ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
                            DEPENDS ${libraries}
                            COMMENT "============== C++ checking ${file} source file...  =================="
                            VERBATIM )
    ENDFOREACH(file)
  ENDIF(OTB_CPP_CHECK_SOURCE_FILE)
891
ENDMACRO(OTB_ADD_EXECUTABLE)
892

893

894 895 896 897 898 899
#-----------------------------------------------------------------------------
# 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)
900
MESSAGE("Warning: utilities compilation is disabled.")
901 902 903 904
LINK_DIRECTORIES("${OTB_BINARY_DIR}/bin")
ENDIF(OTB_DISABLE_UTILITIES_COMPILATION)


905 906 907
#-----------------------------------------------------------------------------
# Option to define streaming activation in applications
# Use by otbConfigure.h.in
908 909
# 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.")
910
MARK_AS_ADVANCED(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING)
911
SET(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING 128000000 CACHE STRING "Max size buffer for streaming.")
912 913 914
MARK_AS_ADVANCED(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING)


915

Thomas Feuvrier's avatar
Thomas Feuvrier committed
916 917 918 919 920
#-----------------------------------------------------------------------------
# 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
921 922 923
IF(OTB_USE_VISU_GUI)
    SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES};${FLTK_PLATFORM_DEPENDENT_LIBS}")
        IF(APPLE)
924
            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
925 926 927 928 929
        ENDIF(APPLE)
ELSE(OTB_USE_VISU_GUI)
        SET(OTB_VISU_GUI_LIBRARIES "")
ENDIF(OTB_USE_VISU_GUI)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
930

931 932 933 934 935 936
#-----------------------------------------------------------------------------
# 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
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962
# # #
# # # 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}")
# # #
963

964
#-----------------------------------------------------------------------------
965
OPTION(BUILD_EXAMPLES "Build the Examples directory." OFF)
966

Thomas Feuvrier's avatar
Thomas Feuvrier committed
967

968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
#-----------------------------------------------------------------------------
# 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}
)

Thomas Feuvrier's avatar
Thomas Feuvrier committed
983 984
#-----------------------------------------------------------------------------
# Dispatch the build into the proper subdirectories.
985

986 987 988 989
#Note: SUBDIRS is deprecated and is replaced by ADD_SUBDIRECTORY
#SUBDIRS(Utilities Code)
ADD_SUBDIRECTORY(Utilities)
ADD_SUBDIRECTORY(Code)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
990 991

IF (BUILD_EXAMPLES)
992
  ADD_SUBDIRECTORY(Examples)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
993 994 995
ENDIF (BUILD_EXAMPLES)

IF (BUILD_TESTING)
996
  ADD_SUBDIRECTORY(Testing)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
997 998 999
ENDIF (BUILD_TESTING)

#-----------------------------------------------------------------------------
1000
# => Comment for OTB 2.6.0: simplification : copy ITK values
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1001
# OTB requires special compiler flags on some platforms.
1002 1003 1004 1005
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
1006 1007 1008 1009
IF(MINGW)
  LINK_LIBRARIES(gdi32)
ENDIF(MINGW)

1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027
#-----------------------------------------------------------------------------
# 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
1028 1029 1030 1031 1032 1033


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
1034 1035
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
1036 1037 1038

#-----------------------------------------------------------------------------
# Configure the default OTB_DATA_ROOT for the location of OTB Data.
1039
FIND_PATH(OTB_DATA_ROOT README-OTB-Data PATHS $ENV{OTB_DATA_ROOT} ${OTB_SOURCE_DIR}/../OTB-Data)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1040 1041
MARK_AS_ADVANCED(OTB_DATA_ROOT)

1042 1043 1044 1045 1046 1047 1048
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
1049 1050 1051

#-----------------------------------------------------------------------------
# Configure files with settings for use by the build.
1052
CONFIGURE_FILE(${OTB_SOURCE_DIR}/otbConfigure.h.in
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1053 1054 1055
               ${OTB_BINARY_DIR}/otbConfigure.h)

#-----------------------------------------------------------------------------
1056
# The entire OTB tree should use the same include path
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1057 1058

# Create the list of include directories needed for OTB header files.
1059
#INCLUDE(${OTB_SOURCE_DIR}/otbIncludeDirectories.cmake)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1060 1061 1062 1063

# 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.
1064 1065 1066 1067 1068
#INCLUDE_DIRECTORIES(
#  ${OTB_INCLUDE_DIRS_BUILD_TREE}
#  ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
#  ${OTB_INCLUDE_DIRS_SYSTEM}
#)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1069 1070 1071

#-----------------------------------------------------------------------------
# Uninstall cmake use to uninstall OTB.
1072 1073 1074 1075
#    CONFIGURE_FILE(
#      "${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in"
#      "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
#      IMMEDIATE @ONLY)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1076

1077 1078
#    ADD_CUSTOM_TARGET(uninstall
#      "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1079 1080 1081 1082 1083 1084 1085 1086

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

1087

Thomas Feuvrier's avatar
Thomas Feuvrier committed
1088 1089 1090
# 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)
1091 1092 1093 1094 1095 1096 1097
#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
1098
    ${OTB_SOURCE_DIR}/CMake/FindOpenThreads.cmake
1099 1100 1101 1102
    DESTINATION ${OTB_INSTALL_PACKAGE_DIR_CM24}
    COMPONENT Development
    )
ENDIF(NOT OTB_INSTALL_NO_DEVELOPMENT)
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1103 1104 1105 1106 1107 1108 1109

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

1110 1111 1112 1113 1114 1115 1116 1117 1118
IF(NOT OTB_INSTALL_NO_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 )
Thomas Feuvrier's avatar
Thomas Feuvrier committed
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128

#-----------------------------------------------------------------------------
# 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}")
1129 1130

#-----------------------------------------------------------------------------
1131 1132 1133
# Set up CPack support, to be able to distribute OTB binary packages. It will
# be particulary useful to distributed prebuilt OTB.
#
1134 1135 1136 1137

OPTION(OTB_USE_CPACK "Generate installer using CPack" OFF)
MARK_AS_ADVANCED(OTB_USE_CPACK)

1138 1139
IF(OTB_USE_CPACK)

1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183
    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)
1184

1185
ENDIF(OTB_USE_CPACK)
1186

1187 1188
FILE(GLOB otbconfigfileCreation_SRCS "${OTB_SOURCE_DIR}/CMake/GenerateConfigProperties.cpp")
SET(otbconfigfile_DEFAULT "${OTB_BINARY_DIR}/otb.conf")
1189

1190 1191 1192 1193 1194 1195 1196
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}"
1197
          COMMENT "Generating ${otbconfigfile_DEFAULT}" )