CMakeLists.txt 10.8 KB
Newer Older
1
PROJECT(Monteverdi)
2 3 4

cmake_minimum_required(VERSION 2.6)

5 6 7 8 9
# CMP0040 : from CMake 3.0, old behaviour is more convenient
if(POLICY CMP0040)
  cmake_policy(SET CMP0040 OLD)
endif()

10 11 12 13 14 15
# CMP0040 : from CMake 3.0 or higher,
# old behaviour is to link to qtmain if explicitly said so.
if(POLICY CMP0020)
  cmake_policy(SET CMP0020 OLD)
endif()

16 17
#----------------------------------------------------------------------------
# Modules
18
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} )
19
include( i18n_qt4 )
20
#include( FindQwt )
21

Stéphane Albert's avatar
Stéphane Albert committed
22 23
#----------------------------------------------------------------------------
# ensure WIN32 definition
24 25 26 27
if(WIN32)
  add_definitions(-DWIN32)
endif(WIN32)

28 29 30 31 32
if(APPLE)
set(CMAKE_MACOSX_RPATH 1)
endif()


33 34 35 36 37 38 39
#----------------------------------------------------------------------------
# ensure DEBUG definitions
#if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
#  add_definitions( -D_DEBUG )
#endif()
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG" )

40
#----------------------------------------------------------------------------
41
# Monteverdi version number.  An even minor number corresponds to releases.
42
set(Monteverdi_VERSION_MAJOR "3")
43
set(Monteverdi_VERSION_MINOR "3")
44
set(Monteverdi_VERSION_PATCH "0")
45
set(Monteverdi_VERSION_SUFFIX "")
46

47
#----------------------------------------------------------------------------
48 49 50 51
# Monteverdi data version number.  An even minor number corresponds to releases.
set(Monteverdi_DATA_VERSION_MAJOR "1")
set(Monteverdi_DATA_VERSION_MINOR "0")
set(Monteverdi_DATA_VERSION_PATCH "0")
52

53 54 55 56 57 58 59
#----------------------------------------------------------------------------
# Monteverdi UI version.
#
# Used to identify UI version for Qt Save/Restore layout. Must be incremented
# each time a widget is added to the UI.
set(Monteverdi_UI_VERSION "1")

60 61 62
#----------------------------------------------------------------------------
# Version string should not include patch level.  The major.minor is
# enough to distinguish available features of the toolkit.
63 64 65
set(
  Monteverdi_VERSION_STRING
  "${Monteverdi_VERSION_MAJOR}.${Monteverdi_VERSION_MINOR}.${Monteverdi_VERSION_PATCH}${Monteverdi_VERSION_SUFFIX}"
66
  )
67

68
#----------------------------------------------------------------------------
69 70 71
set(
  Monteverdi_DATA_VERSION_STRING
  "${Monteverdi_DATA_VERSION_MAJOR}.${Monteverdi_DATA_VERSION_MINOR}.${Monteverdi_DATA_VERSION_PATCH}"
72
  )
73 74

#----------------------------------------------------------------------------
75
set(Monteverdi_FLOATING_TYPE "float" CACHE STRING "The type of data in which input images are read (double/float)." )
76 77 78 79 80

#----------------------------------------------------------------------------
#Prevents conflicts with visual min/max function
#Add the OSSIMSTATIC flag to prevent from including dclspec(dllimport) from ossim
if(WIN32)
81 82 83 84
  if(NOT BUILD_SHARED_LIBS)
    add_definitions(-DNOMINMAX -DOSSIM_STATIC)
  endif()
endif()
85

86
#----------------------------------------------------------------------------
87
# Orfeo ToolBox
88 89 90 91 92
#should we follow modularization here or import all OTB Modules?

#NOTE: If any header from an OTB Module which not listed below is added,
#then below line MUST be updated. At the sametime this ensure only the
#components/modules listed below are linked via OTB_LIBRARIES
93
find_package(OTB REQUIRED
94 95 96 97 98 99 100 101
  COMPONENTS
  OTBApplicationEngine
  OTBQtWidget
  OTBImageIO
  OTBVectorDataIO
  OTBTestKernel
  OTBCarto
  OTBProjection
102 103
  OTBStatistics
  OTBIce)
104

105 106 107
if(OTB_FOUND)
  include(${OTB_USE_FILE})
else(OTB_FOUND)
108
  message(FATAL_ERROR "OTB not found. Please set OTB_DIR")
109 110
endif(OTB_FOUND)

111
#----------------------------------------------------------------------------
112
# OpenGL (needed by Qt4)
113
find_package( OpenGL REQUIRED )
114 115 116

#----------------------------------------------------------------------------
# Qt4
117 118 119 120 121 122
if(CMAKE_VERSION VERSION_GREATER 2.8.11)
  # Disable automatic linking to qtmain on windows
  # as in previous versions of cmake
  cmake_policy(SET CMP0020 OLD)
endif()

123
set(QT_USE_IMPORTED_TARGETS ON)
124
find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtMain QtSql QtXml )
Stéphane Albert's avatar
Stéphane Albert committed
125
include( ${QT_USE_FILE} )
126
if( QT_FOUND )
127 128
  # message( "Qt plugins dir: '${QT_PLUGINS_DIR}'" )
  # message( "Qt translations dir: '${QT_TRANSLATIONS_DIR}'" )
129
endif( QT_FOUND )
130

131 132 133
#----------------------------------------------------------------------------
# Qwt
find_package(Qwt REQUIRED)
134 135 136 137 138 139 140
if(NOT QWT_MAJOR_VERSION EQUAL 5)
  message(FATAL_ERROR "Only Qwt 5 is supported. Found version ${QWT_VERSION_STRING}")
endif()

if(WIN32)
  add_definitions(-DQWT_DLL)
endif(WIN32)
141

142 143 144 145
#----------------------------------------------------------------------------
# Include OTB CMake modules path.
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OTB_SOURCE_DIR}/CMake")

146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
# #----------------------------------------------------------------------------
# find_package(Mercurial QUIET)
# if(Mercurial_FOUND)
#   Mercurial_WC_IDENTIFY(${PROJECT_SOURCE_DIR} Monteverdi)
#   message(STATUS "Mercurial version is ${Mercurial_VERSION_HG}.")
#   message(STATUS "Repository revision is ${Monteverdi_WC_REVISION}.")
#   set(Monteverdi_WC_REVISION ${Monteverdi_WC_REVISION} CACHE STRING "Repository version." FORCE)
#   mark_as_advanced(Monteverdi_WC_REVISION)
#   if(Monteverdi_WC_STATUS)
#     message(STATUS "Local file modifications:")
#     message(STATUS ${Monteverdi_WC_STATUS})
#   else(Monteverdi_WC_STATUS)
#     message(STATUS "No files modified locally")
#   endif(Monteverdi_WC_STATUS)
#   string(REGEX REPLACE "\n" ";" Monteverdi_WC_STATUS "${Monteverdi_WC_STATUS}")
#   set(Monteverdi_WC_STATUS ${Monteverdi_WC_STATUS} CACHE STRING "Repository status." FORCE)
#   mark_as_advanced(Monteverdi_WC_STATUS)
# endif(Mercurial_FOUND)
164 165 166 167 168

#----------------------------------------------------------------------------
#Build shared libraries for monteverdi
#By default, import the option from the OTB configuration

169
set(BUILD_SHARED_LIBS ${OTB_BUILD_SHARED})
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
#----------------------------------------------------------------------------
# Configure the default OTB_DATA_ROOT for the location of OTB Data.
find_path(OTB_DATA_ROOT README-OTB-Data $ENV{OTB_DATA_ROOT})
mark_as_advanced(OTB_DATA_ROOT)

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

#----------------------------------------------------------------------------
# set the Buildname for the dashboard
set(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard.")

187 188
option(Monteverdi_USE_CPACK "Generate installer using CPack" OFF)
mark_as_advanced(Monteverdi_USE_CPACK)
189

190
#----------------------------------------------------------------------------
191
# Installation directories:
192 193 194 195 196
# Monteverdi_INSTALL_BIN_DIR          - binary dir (executables)
# Monteverdi_INSTALL_LIB_DIR          - library dir (libs)
# Monteverdi_INSTALL_DATA_DIR         - share dir (say, examples, data, etc)
# Monteverdi_INSTALL_INCLUDE_DIR      - include dir (headers)
# Monteverdi_INSTALL_PACKAGE_DIR      - package/export configuration files
197

198 199 200
if(NOT Monteverdi_INSTALL_BIN_DIR)
  set(Monteverdi_INSTALL_BIN_DIR "bin")
endif(NOT Monteverdi_INSTALL_BIN_DIR)
201

202 203 204
if(NOT Monteverdi_INSTALL_LIB_DIR)
  set(Monteverdi_INSTALL_LIB_DIR "lib/otb")
endif(NOT Monteverdi_INSTALL_LIB_DIR)
205

206 207 208
if(NOT Monteverdi_INSTALL_DATA_DIR)
  set(Monteverdi_INSTALL_DATA_DIR "share/otb")
endif(NOT Monteverdi_INSTALL_DATA_DIR)
209

210 211 212
if(NOT Monteverdi_INSTALL_INCLUDE_DIR)
  set(Monteverdi_INSTALL_INCLUDE_DIR "include/otb")
endif(NOT Monteverdi_INSTALL_INCLUDE_DIR)
213

214 215 216
if(NOT Monteverdi_INSTALL_PACKAGE_DIR)
  set(Monteverdi_INSTALL_PACKAGE_DIR ${Monteverdi_INSTALL_LIB_DIR})
endif(NOT Monteverdi_INSTALL_PACKAGE_DIR)
217

218 219 220 221
if(APPLE AND Monteverdi_USE_CPACK)
  set(Monteverdi_INSTALL_BIN_DIR "MacOS")
  set(Monteverdi_INSTALL_DATA_DIR "Resources/otb")
endif(APPLE AND Monteverdi_USE_CPACK)
222

223
#----------------------------------------------------------------------------
224 225
include( PreventInSourceBuilds )
include( PreventInstallOnBuildTree )
226
include( DeployQtConf )
227

228
#function to create installer for applications
229
include( MonteverdiApplicationMacros )
230

231
#----------------------------------------------------------------------------
232
# Configure files with settings for use by the build.
233
set( Monteverdi_CONFIGURE_FILE "ConfigureMonteverdi.h" )
234
configure_file(
235 236
  ${Monteverdi_SOURCE_DIR}/${Monteverdi_CONFIGURE_FILE}.in
  ${Monteverdi_BINARY_DIR}/${Monteverdi_CONFIGURE_FILE}
237
  )
238

239
set(Monteverdi_LIBRARY_PROPERTIES
240 241 242
  VERSION   "${Monteverdi_VERSION_MAJOR}.${Monteverdi_VERSION_MINOR}.${Monteverdi_VERSION_PATCH}"
  SOVERSION "${Monteverdi_VERSION_MAJOR}.${Monteverdi_VERSION_MINOR}"
  )
243

244 245 246 247 248 249
#----------------------------------------------------------------------------
# Include the Packaging subdir after every other dir
# since all other install directives must be executed before fixupbundle
#add_subdirectory(Packaging)

#-----------------------------------------------------------------------------
250
# Output (build) directories.
251 252 253
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Monteverdi_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Monteverdi_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Monteverdi_BINARY_DIR}/lib )
254

255
SET(CXX_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
256

257 258 259
#----------------------------------------------------------------------------
# Code location
add_subdirectory( Code )
260

261
# i18n directory must be added after all source files (see add_qt1_i18n_sources).
262
add_subdirectory( i18n )
263

264
# CPack related files
265 266
#We use functions from CMake/CPackFunctions.cmake after OTB 5.0.0
#add_subdirectory( Packaging )
267

268 269
# Data related files
add_subdirectory( Data )
270

271 272 273 274
# SQL related files.
add_subdirectory( Sql )


275
#----------------------------------------------------------------------------
276
# Enable / Disable testing
277 278
option(BUILD_TESTING  "Build testing." OFF)

279 280 281 282 283 284 285 286 287
include(${CMAKE_ROOT}/Modules/Dart.cmake)
configure_file(CMake/CTestCustom.cmake.in CTestCustom.cmake)
mark_as_advanced(TCL_TCLSH DART_ROOT)
if(BUILD_TESTING)
  enable_testing()
  set(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard.")
  mark_as_advanced(BUILDNAME)
  add_subdirectory(Testing)
endif()
288

289 290
#TODO: move this option to Packaging/CMakeLists.txt after big merge!
option(GENERATE_PACKAGE "Generate OTB package" OFF)
Rashad Kanavath's avatar
Rashad Kanavath committed
291 292 293 294 295 296 297 298 299 300 301 302
option(GENERATE_XDK "Generate XDK for OTB development" OFF)

if(GENERATE_PACKAGE OR GENERATE_XDK)
  if(WIN32 OR CMAKE_CROSSCOMPILING)
    set(MXE_TARGET_DIR "" CACHE PATH "path to mxe directory")
    set(OTB_SOURCE_DIR "" CACHE PATH "path to otb source directory")

    if(NOT OTB_SOURCE_DIR)
      message(FATAL_ERROR "OTB_SOURCE_DIR is missing")
    endif()

    add_subdirectory(${OTB_SOURCE_DIR}/SuperBuild/Packaging ${CMAKE_BINARY_DIR}/Packaging)
303

Rashad Kanavath's avatar
Rashad Kanavath committed
304 305
  endif() # (WIN32 OR CMAKE_CROSSCOMPILING)
endif() # (GENERATE_PACKAGE OR GENERATE_XDK)