-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
291 lines (238 loc) · 10.2 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
PROJECT(Monteverdi)
cmake_minimum_required(VERSION 2.6)
# CMP0040 : from CMake 3.0, old behaviour is more convenient
if(POLICY CMP0040)
cmake_policy(SET CMP0040 OLD)
endif()
# 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()
#----------------------------------------------------------------------------
# Modules
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} )
include( i18n_qt4 )
#include( FindQwt )
#----------------------------------------------------------------------------
# ensure WIN32 definition
if(WIN32)
add_definitions(-DWIN32)
endif(WIN32)
if(APPLE)
set(CMAKE_MACOSX_RPATH 1)
endif()
#----------------------------------------------------------------------------
# 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" )
#----------------------------------------------------------------------------
# Monteverdi version number. An even minor number corresponds to releases.
set(Monteverdi_VERSION_MAJOR "3")
set(Monteverdi_VERSION_MINOR "2")
set(Monteverdi_VERSION_PATCH "0")
set(Monteverdi_VERSION_SUFFIX "")
#----------------------------------------------------------------------------
# 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")
#----------------------------------------------------------------------------
# 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")
#----------------------------------------------------------------------------
# Version string should not include patch level. The major.minor is
# enough to distinguish available features of the toolkit.
set(
Monteverdi_VERSION_STRING
"${Monteverdi_VERSION_MAJOR}.${Monteverdi_VERSION_MINOR}.${Monteverdi_VERSION_PATCH}${Monteverdi_VERSION_SUFFIX}"
)
#----------------------------------------------------------------------------
set(
Monteverdi_DATA_VERSION_STRING
"${Monteverdi_DATA_VERSION_MAJOR}.${Monteverdi_DATA_VERSION_MINOR}.${Monteverdi_DATA_VERSION_PATCH}"
)
#----------------------------------------------------------------------------
set(Monteverdi_FLOATING_TYPE "float" CACHE STRING "The type of data in which input images are read (double/float)." )
#----------------------------------------------------------------------------
#Prevents conflicts with visual min/max function
#Add the OSSIMSTATIC flag to prevent from including dclspec(dllimport) from ossim
if(WIN32)
if(NOT BUILD_SHARED_LIBS)
add_definitions(-DNOMINMAX -DOSSIM_STATIC)
endif()
endif()
#----------------------------------------------------------------------------
# Orfeo ToolBox
#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
find_package(OTB REQUIRED
COMPONENTS
OTBApplicationEngine
OTBQtWidget
OTBImageIO
OTBVectorDataIO
OTBTestKernel
OTBCarto
OTBProjection
OTBStatistics
OTBIce)
if(OTB_FOUND)
include(${OTB_USE_FILE})
else(OTB_FOUND)
message(FATAL_ERROR "OTB not found. Please set OTB_DIR")
endif(OTB_FOUND)
#----------------------------------------------------------------------------
# OpenGL (needed by Qt4)
find_package( OpenGL REQUIRED )
#----------------------------------------------------------------------------
# Qt4
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()
set(QT_USE_IMPORTED_TARGETS ON)
find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtMain QtSql QtXml )
include( ${QT_USE_FILE} )
if( QT_FOUND )
# message( "Qt plugins dir: '${QT_PLUGINS_DIR}'" )
# message( "Qt translations dir: '${QT_TRANSLATIONS_DIR}'" )
endif( QT_FOUND )
#----------------------------------------------------------------------------
# Qwt
find_package(Qwt REQUIRED)
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)
#----------------------------------------------------------------------------
# Include OTB CMake modules path.
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OTB_SOURCE_DIR}/CMake")
# #----------------------------------------------------------------------------
# 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)
#----------------------------------------------------------------------------
#Build shared libraries for monteverdi
#By default, import the option from the OTB configuration
set(BUILD_SHARED_LIBS ${OTB_BUILD_SHARED})
#----------------------------------------------------------------------------
# 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.")
option(Monteverdi_USE_CPACK "Generate installer using CPack" OFF)
mark_as_advanced(Monteverdi_USE_CPACK)
#----------------------------------------------------------------------------
# Installation directories:
# 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
if(NOT Monteverdi_INSTALL_BIN_DIR)
set(Monteverdi_INSTALL_BIN_DIR "bin")
endif(NOT Monteverdi_INSTALL_BIN_DIR)
if(NOT Monteverdi_INSTALL_LIB_DIR)
set(Monteverdi_INSTALL_LIB_DIR "lib/otb")
endif(NOT Monteverdi_INSTALL_LIB_DIR)
if(NOT Monteverdi_INSTALL_DATA_DIR)
set(Monteverdi_INSTALL_DATA_DIR "share/otb")
endif(NOT Monteverdi_INSTALL_DATA_DIR)
if(NOT Monteverdi_INSTALL_INCLUDE_DIR)
set(Monteverdi_INSTALL_INCLUDE_DIR "include/otb")
endif(NOT Monteverdi_INSTALL_INCLUDE_DIR)
if(NOT Monteverdi_INSTALL_PACKAGE_DIR)
set(Monteverdi_INSTALL_PACKAGE_DIR ${Monteverdi_INSTALL_LIB_DIR})
endif(NOT Monteverdi_INSTALL_PACKAGE_DIR)
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)
#----------------------------------------------------------------------------
include( PreventInSourceBuilds )
include( PreventInstallOnBuildTree )
include( DeployQtConf )
#function to create installer for applications
include( MonteverdiApplicationMacros )
#----------------------------------------------------------------------------
# Configure files with settings for use by the build.
set( Monteverdi_CONFIGURE_FILE "ConfigureMonteverdi.h" )
configure_file(
${Monteverdi_SOURCE_DIR}/${Monteverdi_CONFIGURE_FILE}.in
${Monteverdi_BINARY_DIR}/${Monteverdi_CONFIGURE_FILE}
)
set(Monteverdi_LIBRARY_PROPERTIES
VERSION "${Monteverdi_VERSION_MAJOR}.${Monteverdi_VERSION_MINOR}.${Monteverdi_VERSION_PATCH}"
SOVERSION "${Monteverdi_VERSION_MAJOR}.${Monteverdi_VERSION_MINOR}"
)
#----------------------------------------------------------------------------
# Include the Packaging subdir after every other dir
# since all other install directives must be executed before fixupbundle
#add_subdirectory(Packaging)
#-----------------------------------------------------------------------------
# Output (build) directories.
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 )
SET(CXX_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
#----------------------------------------------------------------------------
# Code location
add_subdirectory( Code )
# i18n directory must be added after all source files (see add_qt1_i18n_sources).
add_subdirectory( i18n )
# CPack related files
#We use functions from CMake/CPackFunctions.cmake after OTB 5.0.0
#add_subdirectory( Packaging )
# Data related files
add_subdirectory( Data )
# SQL related files.
add_subdirectory( Sql )
#----------------------------------------------------------------------------
# Enable / Disable testing
option(BUILD_TESTING "Build testing." OFF)
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()
if(WIN32 OR CMAKE_CROSSCOMPILING)
add_subdirectory(Packaging)
endif() # (WIN32 OR CMAKE_CROSSCOMPILING)