-
Notifications
You must be signed in to change notification settings - Fork 114
/
CMakeLists.txt
654 lines (551 loc) · 22.4 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
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
336
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
405
406
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
#
# Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.13.0)
foreach(p
CMP0072 # CMake 3.11
CMP0078 # CMake 3.13
CMP0086 # CMake 3.14
)
if(POLICY ${p})
cmake_policy(SET ${p} NEW)
endif()
endforeach()
project(OTB)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Check compiler versions
set(OTB_MIN_GNU_VER 5)
set(OTB_MIN_MSVC_VER 19)
set(OTB_MIN_Clang_VER 3.4)
if(DEFINED OTB_MIN_${CMAKE_CXX_COMPILER_ID}_VER)
if(CMAKE_CXX_COMPILER_VERSION AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${OTB_MIN_${CMAKE_CXX_COMPILER_ID}_VER})
message(FATAL_ERROR "The version of your ${CMAKE_CXX_COMPILER_ID} "
"compiler is not supported by Orfeo ToolBox. Please consider updating your compiler to version "
"${OTB_MIN_${CMAKE_CXX_COMPILER_ID}_VER} or later.")
endif()
endif()
include(CMakeDependentOption)
#
# use ExternalProject
include(ExternalProject)
if( CMAKE_HOST_WIN32 )
string( LENGTH "${CMAKE_CURRENT_SOURCE_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"OTB source code directory path length is too long (${n} > 50)."
"Please move the OTB source code directory to a directory with a shorter path."
)
endif()
string( LENGTH "${CMAKE_CURRENT_BINARY_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"OTB build directory path length is too long (${n} > 50)."
"Please set the OTB build directory to a directory with a shorter path."
)
endif()
endif()
set(OTB_APPLICATIONS_NAME_LIST "" CACHE STRING "List of all applications" FORCE)
mark_as_advanced(OTB_APPLICATIONS_NAME_LIST)
set(OTB_CMAKE_DIR ${OTB_SOURCE_DIR}/CMake)
set(CMAKE_MODULE_PATH ${OTB_CMAKE_DIR} ${CMAKE_MODULE_PATH})
include(SourceStatus)
include(GetVersionFromGitTag)
include(PreventInSourceBuilds)
include(PreventInBuildInstalls)
include(OTBModuleMacros)
include(OTBModuleRemote)
include(OTBModuleTest)
repository_status(${PROJECT_SOURCE_DIR} OTB_GIT_STATUS_MESSAGE)
if(OTB_WRAP_PYTHON)
find_package(Python REQUIRED COMPONENTS Interpreter Development)
if(Python_FOUND)
message(STATUS "Python Library directory : ${Python_LIBRARY_DIRS}")
message(STATUS "Python Headers directory : ${Python_INCLUDE_DIRS}")
endif()
endif()
#-----------------------------------------------------------------------------
# Configure the default OTB_DATA_ROOT for the location of OTB Data.
find_path(OTB_DATA_ROOT
NAMES README-OTB-Data
HINTS ${OTB_SOURCE_DIR}/Data
)
#mark_as_advanced(OTB_DATA_ROOT)
if(OTB_DATA_ROOT)
repository_status(${OTB_DATA_ROOT} OTB_DATA_GIT_STATUS_MESSAGE)
endif()
set(main_project_name ${_OTBModuleMacros_DEFAULT_LABEL})
#-----------------------------------------------------------------------------
# OTB version number.
set(OTB_VERSION_MAJOR "9")
set(OTB_VERSION_MINOR "1")
set(OTB_VERSION_PATCH "0")
set(OTB_VERSION_STRING "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH}")
get_package_name(${OTB_SOURCE_DIR} ${PROJECT_NAME} OTB_VERSION_STRING2)
include(OTBConstants)
#-----------------------------------------------------------------------------
string(TIMESTAMP OTB_BUILD_TIMESTAMP)
# init all OTB_INSTALL const var
get_install_const()
if(NOT OTB_INSTALL_PYTHON_DIR)
set(OTB_INSTALL_PYTHON_DIR "${OTB_INSTALL_LIBRARY_DIR}/otb/python")
endif()
#convert path to native for reconfiguring otbcli.bat.in
file(TO_NATIVE_PATH "${OTB_INSTALL_APP_DIR}" OTB_INSTALL_APP_DIR_NATIVE)
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
#-----------------------------------------------------------------------------
# Enable running cppcheck for each module on its source and test directories.
option(OTB_CPPCHECK_TEST "Run cppcheck for static code analysis" OFF)
mark_as_advanced(OTB_CPPCHECK_TEST)
#-----------------------------------------------------------------------------
# Forbid downloading resources from the network during a build. This helps
# when building on systems without network connectivity to determine which
# resources much be obtained manually and made available to the build.
option(OTB_FORBID_DOWNLOADS "Do not download source code or data from the network" OFF)
mark_as_advanced(OTB_FORBID_DOWNLOADS)
macro(otb_download_attempt_check _name)
if(OTB_FORBID_DOWNLOADS)
message(SEND_ERROR "Attempted to download ${_name} when OTB_FORBID_DOWNLOADS is ON")
endif()
endmacro()
# TODO : handle shared libs on windows
option(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON)
mark_as_advanced(BUILD_SHARED_LIBS)
if(MSVC)
option(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "Build OTB with shared libraries." ON)
mark_as_advanced(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS)
set(OTB_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
else()
set(OTB_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
endif()
# Although the OpenMP option looks like a 3rd party module, it is NOT. This option
# is handled with other compilation flags in file OTBSetStandardCompilerFlags.cmake
# before any module is parsed or enabled (see OTBModuleEnablement.cmake later on
# during configure). Trying to modify this option from any module is
# useless. Any 3rd party module dragging OpenMP should append
# the corresponding flags to CMAKE_CXX_FLAGS, CMAKE_EXE_LINKER_FLAGS, and so on.
option(OTB_USE_OPENMP "Add openmp compiler and linker flags" OFF)
option(OTB_USE_SSE_FLAGS "Enable SIMD optimizations (hardware dependent)." ON)
mark_as_advanced(OTB_USE_SSE_FLAGS)
include(OTBSetStandardCompilerFlags)
#---------------------------------------------------------------
# run try compiles and tests for OTB
# TODO check if we need this
#include(otbTestFriendTemplatedFunction)
set(CMAKE_C_FLAGS "${OTB_REQUIRED_C_FLAGS} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}")
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
# TODO BUILD_TESTING is created by default by CTest.cmake, and is ON by default.
option(BUILD_TESTING "Build the testing tree." OFF)
include(CTest)
include( CppcheckTargets )
# Setup build locations.
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OTB_BINARY_DIR}/bin)
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OTB_BINARY_DIR}/lib)
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OTB_BINARY_DIR}/lib)
endif()
set(OTB_MODULES_DIRS "${OTB_BINARY_DIR}/${OTB_INSTALL_PACKAGE_DIR}/Modules")
#-----------------------------------------------------------------------------
# By default, OTB does not build the Examples that are illustrated in the Software Guide
option(BUILD_EXAMPLES "Build the Examples directory." OFF)
#----------------------------------------------------------------------------
set(OTB_TEST_OUTPUT_DIR "${OTB_BINARY_DIR}/Testing/Temporary")
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
NAMES OTBData.readme
HINTS $ENV{OTB_DATA_LARGEINPUT_ROOT}
)
mark_as_advanced(OTB_DATA_LARGEINPUT_ROOT)
endif()
# Small macro to copy a file and rename it
macro(otb_copy_rename _input _output)
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_input}" "${_output}"
RESULT_VARIABLE _err_code
OUTPUT_QUIET
ERROR_QUIET
)
if(_err_code)
message(FATAL_ERROR "Failed to copy file ${_input} to ${_output}")
endif()
endmacro()
#Generate cmake variables with a set of largeinput data used in tests
include(OTBManageLargeInputPaths)
set(BASELINE ${OTB_DATA_ROOT}/Baseline/OTB/Images)
set(BASELINE_FILES ${OTB_DATA_ROOT}/Baseline/OTB/Files)
set(INPUTDATA ${OTB_DATA_ROOT}/Input)
set(TEMP ${OTB_BINARY_DIR}/Testing/Temporary)
set(OTBAPP_BASELINE ${OTB_DATA_ROOT}/Baseline/OTB-Applications/Images)
set(OTBAPP_BASELINE_FILES ${OTB_DATA_ROOT}/Baseline/OTB-Applications/Files)
# init all EPSILON_X vars used for unit test
get_test_const()
# Location of OTB Example Data.
set(OTB_EXAMPLE_DATA_ROOT "${OTB_SOURCE_DIR}/Examples/Data")
#----------------------------------------------------------------------
# Make sure remote modules are downloaded before sorting out the module
# dependencies.
add_subdirectory(Modules/Remote)
# Enable modules according to user inputs and the module dependency DAG.
include(OTBModuleEnablement)
#----------------------------------------------------------------------
# Generate OTBConfig.cmake for the build tree.
set(OTB_CONFIG_CODE "
set(OTB_MODULES_DIRS \"${OTB_MODULES_DIRS}\")")
set(OTB_CONFIG_CMAKE_DIR "${OTB_SOURCE_DIR}/CMake")
set(OTB_USE_FILE "${OTB_CONFIG_CMAKE_DIR}/UseOTB.cmake")
if(OTB_WRAP_PYTHON)
set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_PYTHONPATH \"${OTB_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR}\")")
endif()
set(OTB_CONFIG_APPLICATION_PATH "${OTB_BINARY_DIR}/${OTB_INSTALL_APP_DIR}")
set(OTB_CONFIG_MODULE_API_FILE "${OTB_SOURCE_DIR}/CMake/OTBModuleAPI.cmake")
set(OTB_CONFIG_APPLI_MACROS_FILE "${OTB_SOURCE_DIR}/CMake/OTBApplicationMacros.cmake")
configure_file(CMake/OTBConfig.cmake.in OTBConfig.cmake @ONLY)
# Generate OTBConfig.cmake for the install tree.
set(OTB_CONFIG_CODE "
# Compute the installation prefix from this OTBConfig.cmake file location.
get_filename_component(OTB_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
# Construct the proper number of get_filename_component(... PATH)
# calls to compute the installation prefix.
string(REGEX REPLACE "/" ";" _count "${OTB_INSTALL_PACKAGE_DIR}")
foreach(p ${_count})
set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
get_filename_component(OTB_INSTALL_PREFIX \"\${OTB_INSTALL_PREFIX}\" PATH)")
endforeach()
set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_MODULES_DIRS \"\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/Modules\")")
set(OTB_USE_FILE "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/UseOTB.cmake")
set(OTB_CONFIG_CMAKE_DIR "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}")
if(OTB_WRAP_PYTHON)
set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_PYTHONPATH \"\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PYTHON_DIR}\")")
endif()
set(OTB_CONFIG_APPLICATION_PATH "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_APP_DIR}")
set(OTB_CONFIG_MODULE_API_FILE "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/OTBModuleAPI.cmake")
set(OTB_CONFIG_APPLI_MACROS_FILE "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/OTBApplicationMacros.cmake")
configure_file(CMake/OTBConfig.cmake.in CMakeFiles/OTBConfig.cmake @ONLY)
# TODO : port unscrustify scripts from ITK to OTB ?
# #----------------------------------------------------------------------------
# # Configure maintenance scripts
# configure_file(Utilities/Maintenance/doSingleKWStyleUncrustifyFix.sh.in
# Utilities/Maintenance/doSingleKWStyleUncrustifyFix.sh @ONLY)
#-----------------------------------------------------------------------------
configure_file(CMake/OTBConfigVersion.cmake.in OTBConfigVersion.cmake @ONLY)
install(FILES ${OTB_BINARY_DIR}/CMakeFiles/OTBConfig.cmake
${OTB_BINARY_DIR}/OTBConfigVersion.cmake
CMake/OTBApplicationMacros.cmake
CMake/OTBModuleAPI.cmake
CMake/OTBStandaloneModuleMacros.cmake
CMake/OTBConstants.cmake
CMake/OTBModuleExternal.cmake
CMake/UseOTB.cmake
CMake/GenerateExportHeaderCustom.cmake
CMake/exportheader.cmake.in
CMake/NamespaceHandler.cmake
# both CMake files used for P0 modules
CMake/OTBModuleInfo.cmake.in
CMake/GenericGroupConfig.cmake.in
DESTINATION ${OTB_INSTALL_PACKAGE_DIR}
COMPONENT Core)
if(XDK_INSTALL_PATH)
# In order to package the external libraries built by the SuperBuild, we have to "unpack" this xdk in the current build directory and tell
# Cmake it is here
message(STATUS "XDK FOUND, preparing it for packaging")
install(DIRECTORY ${XDK_INSTALL_PATH}/lib
DESTINATION .
USE_SOURCE_PERMISSIONS
COMPONENT Dependencies)
# Redhat8 case : the bindings are installed by default in lib64/python3.8
if( EXISTS ${XDK_INSTALL_PATH}/lib64)
install(DIRECTORY ${XDK_INSTALL_PATH}/lib64/python3.8
DESTINATION ./lib
USE_SOURCE_PERMISSIONS
COMPONENT Dependencies)
endif()
install(DIRECTORY ${XDK_INSTALL_PATH}/share
DESTINATION .
USE_SOURCE_PERMISSIONS
COMPONENT Core)
install(DIRECTORY ${XDK_INSTALL_PATH}/include
DESTINATION .
USE_SOURCE_PERMISSIONS
COMPONENT Core)
install(DIRECTORY ${XDK_INSTALL_PATH}/bin
DESTINATION .
USE_SOURCE_PERMISSIONS
COMPONENT Core)
install(DIRECTORY ${XDK_INSTALL_PATH}/cmake
DESTINATION ./lib
USE_SOURCE_PERMISSIONS
COMPONENT Core)
else()
message(WARNING "XDK NOT FOUND, it will not be packaged")
endif()
# install FindXXX.cmake
file(GLOB OTB_FIND_PACKAGE_SCRIPTS CMake/Find*.cmake)
install(FILES ${OTB_FIND_PACKAGE_SCRIPTS} DESTINATION ${OTB_INSTALL_PACKAGE_DIR} COMPONENT Core)
# TODO : install release notes, copyright notice, ...
install(FILES "LICENSE" DESTINATION . COMPONENT Core)
# Configure and install VERSION file
configure_file(VERSION VERSION @ONLY)
install(FILES ${OTB_BINARY_DIR}/VERSION DESTINATION ${OTB_INSTALL_DOC_DIR})
if(EXISTS ${OTB_BINARY_DIR}/${OTB_INSTALL_DATA_DIR})
message("Directory share/otb already exists")
else()
file(MAKE_DIRECTORY ${OTB_BINARY_DIR}/${OTB_INSTALL_DATA_DIR})
endif()
install(DIRECTORY ${OTB_BINARY_DIR}/${OTB_INSTALL_DATA_DIR} DESTINATION share COMPONENT Core)
install(FILES Packaging/Files/build_wrapping.cmake
DESTINATION ./share/otb/swig
COMPONENT Core)
install(FILES Packaging/Files/build_wrapping.md
DESTINATION ./share/otb/swig
RENAME README.md
COMPONENT Core)
#start installing script and other stuff related to package
if(UNIX)
install( PROGRAMS
${OTB_SOURCE_DIR}/Packaging/Files/recompile_bindings.sh
${OTB_SOURCE_DIR}/Packaging/Files/otbenv.profile
DESTINATION .
COMPONENT Core
)
configure_file(${OTB_SOURCE_DIR}/Packaging/Files/post_install.sh.in
${CMAKE_BINARY_DIR}/post_install.sh @ONLY)
install( PROGRAMS
${OTB_SOURCE_DIR}/Packaging/Files/check_python_env.sh
${CMAKE_BINARY_DIR}/post_install.sh
${OTB_SOURCE_DIR}/Packaging/Files/sanitize_rpath.sh
DESTINATION ./tools
COMPONENT Core
)
endif()
#my_file_ext is required for otbcli files which has
# no extension on linux. (hence we cannot use SCRIPT_EXT
#For windows otbenv.bash and otbenv.bat is required.
# Former is for windows shell users and latter is for other
# linux emulator such as bash for windows or mobxterm
set(my_file_ext "")
if(WIN32)
set(my_file_ext ".bat")
install( PROGRAMS
${OTB_SOURCE_DIR}/Packaging/Files/otbenv.bat
${OTB_SOURCE_DIR}/Packaging/Files/otbenv.ps1
${OTB_SOURCE_DIR}/Packaging/Files/otbenv.bash
DESTINATION .
COMPONENT Core
)
endif()
# #configure README from rst docs
set(RSTDOC_DIR "${OTB_SOURCE_DIR}/Documentation/Cookbook/rst")
if(WIN32) #windows
set(README_FILE ${RSTDOC_DIR}/Installation_Windows.rst)
else()
set(README_FILE ${RSTDOC_DIR}/Installation_Linux.rst)
endif()
configure_file("${README_FILE}" ${CMAKE_BINARY_DIR}/README )
install(FILES ${CMAKE_BINARY_DIR}/README DESTINATION . COMPONENT Core)
if(BUILD_TESTING)
add_subdirectory(Utilities/InstallTest)
endif()
#-----------------------------------------------------------------------------
# The subdirectories added below this line should use only the public
# interface with find_package(ITK). Set ITK_DIR to use this ITK build.
set(OTB_DIR "${OTB_BINARY_DIR}")
if(BUILD_EXAMPLES)
add_subdirectory(Examples)
endif()
#----------------------------------------------------------------------
# Provide an option for generating documentation.
add_subdirectory(Utilities/Doxygen)
add_subdirectory(Utilities/Completion)
option(BUILD_COOKBOOK "Build the CookBook documentation." OFF)
if (BUILD_COOKBOOK)
add_subdirectory(Documentation/Cookbook)
endif()
#----------------------------------------------------------------------------
# Provide a target to generate the SuperBuild archive (only for Unix)
if(UNIX)
add_custom_target(SuperBuild-archive
COMMAND ./SuperbuildDownloadList.sh
${OTB_BINARY_DIR}/Download
${OTB_BINARY_DIR}
WORKING_DIRECTORY ${OTB_SOURCE_DIR}/CI
)
endif()
# TODO cleanup
# Create target to download data from the OTBData group. This must come after
# all tests have been added that reference the group, so we put it last.
#-----------------------------------------------------------------------------
# uninstall target
configure_file(
"${CMAKE_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
#-----------------------------------------------------------------------------
#macro to put a fixed space between key, value in summary
macro(get_white_spaces var res)
string(LENGTH "${var}" len)
math(EXPR required_spaces "23 - ${len}")
set(${res})
foreach(loop_var RANGE ${required_spaces})
set(${res} "${${res}} ")
endforeach()
endmacro()
message("\n======================= Begin of OTB cmake summary =======================\n")
if(OTB_GIT_STATUS_MESSAGE)
message( ${OTB_GIT_STATUS_MESSAGE})
endif()
if(OTB_DATA_GIT_STATUS_MESSAGE)
message( ${OTB_DATA_GIT_STATUS_MESSAGE})
endif()
set(option_list ${OTB_MODULE_ACTIVATION_OPTION_LIST})
list(SORT option_list)
foreach(otb_option
CMAKE_SOURCE_DIR
CMAKE_BINARY_DIR
CMAKE_INSTALL_PREFIX
CMAKE_COMMAND
CMAKE_C_COMPILER
CMAKE_CXX_COMPILER
CMAKE_MAKE_PROGRAM
CMAKE_GENERATOR
CMAKE_BUILD_TYPE
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
${option_list}
OTB_WRAP_PYTHON
OTB_WRAP_QGIS
OTB_DATA_ROOT
OTB_USE_OPENMP
OTB_USE_SSE_FLAGS
)
get_white_spaces("${otb_option}" spaces)
message("${otb_option} ${spaces} = ${${otb_option}}")
endforeach()
# Cleaning option_list as we are using a new one now
unset(option_list)
#To report non-optional dependencies inside summary
list(APPEND option_list Boost)
list(APPEND option_list GDAL)
list(APPEND option_list GEOTIFF)
list(APPEND option_list ITK)
list(APPEND option_list TINYXML)
#sort again!
list(SORT option_list)
foreach(dep ${option_list})
string(REGEX REPLACE "OTB_USE_" "" dep ${dep})
unset(var1_key)
unset(var2_key)
unset(var3_key)
unset(var1_val)
unset(var2_val)
unset(var3_val)
set(var1_key "${dep}")
if(${dep}_VERSION_STRING)
set(var1_val ${${dep}_VERSION_STRING})
endif()
if(NOT var1_val)
if(${dep}_VERSION)
set(var1_val ${${dep}_VERSION})
endif()
endif()
if(DEFINED ${dep}_DIR)
set(var2_key ${dep}_DIR)
set(var2_val ${${dep}_DIR})
else()
if(${dep}_INCLUDE_DIR)
set(var2_key ${dep}_INCLUDE_DIR)
set(var2_val ${${dep}_INCLUDE_DIR})
elseif(${dep}_INCLUDE_DIRS)
set(var2_key ${dep}_INCLUDE_DIRS)
set(var2_val ${${dep}_INCLUDE_DIRS})
endif()
if(${dep}_LIBRARY)
set(var3_key ${dep}_LIBRARY)
set(var3_val ${${dep}_LIBRARY})
elseif(${dep}_LIBRARIES)
set(var3_key ${dep}_LIBRARIES)
set(var3_val ${${dep}_LIBRARIES})
endif()
endif()
get_white_spaces("${var1_key}" insert_spaces1)
get_white_spaces("${var2_key}" insert_spaces2)
get_white_spaces("${var3_key}" insert_spaces3)
message("${var1_key} ${insert_spaces1} = ${var1_val}")
if(var2_val)
message("${var2_key} ${insert_spaces2} = ${var2_val}")
endif()
if(var3_val)
message("${var3_key} ${insert_spaces3} = ${var3_val}")
endif()
endforeach()
message("\nCMake ${CMAKE_VERSION} successfully configured ${PROJECT_NAME} using ${CMAKE_GENERATOR} generator\n")
message("======================= End of OTB cmake summary =======================")
# create all needed config files here
get_property(GROUPS_ENABLED GLOBAL PROPERTY OTB_GROUPS_ENABLED)
foreach(otb-group IN LISTS GROUPS_ENABLED)
get_property(GROUP_DEPS GLOBAL PROPERTY ${otb-group}_MOD_DEPS)
set(__ENABLED_MODULES ${OTB_${otb-group}_MODULES_ENABLED})
configure_file(CMake/GenericGroupConfig.cmake.in CMakeFiles/${otb-group}Config.cmake @ONLY)
install(FILES ${OTB_BINARY_DIR}/CMakeFiles/${otb-group}Config.cmake
DESTINATION ${OTB_INSTALL_PACKAGE_DIR}
COMPONENT ${otb-group})
unset(__ENABLED_MODULES)
endforeach() # otb-group IN GROUPS_ENABLED
#don't need this one anymore. so unset it.
unset(option_list)
#----------------------------------------------------------------------------
include(Packaging_OTB)