External_otb.cmake 6.85 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#
# Copyright (C) 2005-2017 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.
#

21
INCLUDE_ONCE_MACRO(OTB)
22

23
SETUP_SUPERBUILD(OTB)
24

25
set(OTB_SB_SRC ${CMAKE_SOURCE_DIR}/..)
Rashad Kanavath's avatar
Rashad Kanavath committed
26

27
ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB GDAL OSSIM ITK TINYXML BOOST)
Rashad Kanavath's avatar
Rashad Kanavath committed
28 29

##get_property(OTB_DEPENDENCIES GLOBAL PROPERTY GLOBAL_OTB_DEPENDENCIES)
30 31

if(OTB_USE_CURL)
Rashad Kanavath's avatar
Rashad Kanavath committed
32
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB CURL)
33 34
  ADD_SUPERBUILD_CMAKE_VAR(OTB CURL_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB CURL_LIBRARY)
35
endif()
36

37
if(OTB_USE_LIBKML)
38 39 40 41 42 43 44 45 46
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB LIBKML)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBKML_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBKML_BASE_LIBRARY)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBKML_CONVENIENCE_LIBRARY)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBKML_DOM_LIBRARY)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBKML_ENGINE_LIBRARY)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBKML_REGIONATOR_LIBRARY)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBKML_XSD_LIBRARY)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBKML_MINIZIP_LIBRARY)
47 48 49
endif()

if(OTB_USE_OPENCV)
50
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB OPENCV)
51
  ADD_SUPERBUILD_CMAKE_VAR(OTB OpenCV_DIR)
52 53
endif()

54 55
if(OTB_USE_SHARK)
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB SHARK)
56
  ADD_SUPERBUILD_CMAKE_VAR(OTB Shark_DIR)
57 58
endif()

59
if(OTB_USE_LIBSVM)
60
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB LIBSVM)
61 62
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBSVM_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB LIBSVM_LIBRARY)
63 64
endif()

65
if(OTB_USE_MUPARSER)
66
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB MUPARSER)
67 68
  ADD_SUPERBUILD_CMAKE_VAR(OTB MUPARSER_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB MUPARSER_LIBRARY)
69 70 71
endif()

if(OTB_USE_MUPARSERX)
72
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB MUPARSERX)
73 74
  ADD_SUPERBUILD_CMAKE_VAR(OTB MUPARSERX_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB MUPARSERX_LIBRARY)
75 76
endif()

77
if(OTB_WRAP_PYTHON OR OTB_WRAP_JAVA OR OTB_WRAP_PYTHON3)
78
  ADD_SUPERBUILD_CMAKE_VAR(OTB SWIG_EXECUTABLE)
79
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB SWIG)
80
endif()
81

82 83 84
if(OTB_WRAP_PYTHON)
  ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON_LIBRARY)
85
  ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON_EXECUTABLE)
86 87
endif()

88 89 90 91 92 93
if(OTB_WRAP_PYTHON3)
  ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON3_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON3_LIBRARY)
  ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON3_EXECUTABLE)
endif()

94
if(OTB_USE_QT)
95 96 97
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB QT5)
endif()

98
if(OTB_USE_GLEW)
99
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB GLEW)
100 101
  ADD_SUPERBUILD_CMAKE_VAR(OTB GLEW_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB GLEW_LIBRARY)
102 103 104
endif()

if(OTB_USE_GLFW)
105
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB GLFW)
106 107 108
  #check with RK before enabling it again (clean up to be done)
  # ADD_SUPERBUILD_CMAKE_VAR(OTB GLFW_INCLUDE_DIR)
  # ADD_SUPERBUILD_CMAKE_VAR(OTB GLFW_LIBRARY)
109 110 111
endif()

if(OTB_USE_GLUT)
112
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB GLUT)
113 114
  ADD_SUPERBUILD_CMAKE_VAR(OTB GLUT_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB GLUT_LIBRARY)
115
endif()
116

117 118 119 120 121 122
if(OTB_USE_QWT)
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB QWT)
  ADD_SUPERBUILD_CMAKE_VAR(OTB QWT_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB QWT_LIBRARY)
endif()

123 124 125 126 127 128 129
if(OTB_USE_GSL)
  ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB GSL)
  ADD_SUPERBUILD_CMAKE_VAR(OTB GSL_INCLUDE_DIR)
  ADD_SUPERBUILD_CMAKE_VAR(OTB GSL_LIBRARY)
endif()


Rashad Kanavath's avatar
Rashad Kanavath committed
130 131
ADD_SUPERBUILD_CMAKE_VAR(OTB GDAL_INCLUDE_DIR)
ADD_SUPERBUILD_CMAKE_VAR(OTB GDAL_LIBRARY)
132

Rashad Kanavath's avatar
Rashad Kanavath committed
133 134
ADD_SUPERBUILD_CMAKE_VAR(OTB OSSIM_INCLUDE_DIR)
ADD_SUPERBUILD_CMAKE_VAR(OTB OSSIM_LIBRARY)
135

Rashad Kanavath's avatar
Rashad Kanavath committed
136
ADD_SUPERBUILD_CMAKE_VAR(OTB ITK_DIR)
137

Rashad Kanavath's avatar
Rashad Kanavath committed
138 139
ADD_SUPERBUILD_CMAKE_VAR(OTB TINYXML_INCLUDE_DIR)
ADD_SUPERBUILD_CMAKE_VAR(OTB TINYXML_LIBRARY)
140

Rashad Kanavath's avatar
Rashad Kanavath committed
141 142
ADD_SUPERBUILD_CMAKE_VAR(OTB Boost_INCLUDE_DIR)
ADD_SUPERBUILD_CMAKE_VAR(OTB Boost_LIBRARY_DIR)
143

144 145 146

set(OTB_MODULES_CONFIG)
if(WITH_REMOTE_MODULES)
147
  foreach(remote_module SertitObject Mosaic otbGRM OTBFFSforGMM)
148 149
    list(APPEND OTB_MODULES_CONFIG -DModule_${remote_module}:BOOL=ON)
  endforeach()
150

151
  # Add CESBIO'S remote modules if OTB is compiled with GSL support (for now only TemporalGapFilling)
152
  if(OTB_USE_GSL)
153
    foreach(remote_module OTBTemporalGapFilling)
154 155 156
      list(APPEND OTB_MODULES_CONFIG -DModule_${remote_module}:BOOL=ON)
    endforeach()
  endif()
157 158 159 160 161
else()
  set(OTB_MODULES_CONFIG)
endif()


162 163 164 165 166
add_custom_command(OUTPUT otb_depends_done.txt
  COMMAND cmake -E touch otb_depends_done.txt
  DEPENDS ${OTB_DEPENDENCIES}
  )

167
add_custom_target(OTB_DEPENDS
168 169 170 171 172 173
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/otb_depends_done.txt
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  COMMENT "Built all otb dependencies: ${OTB_DEPENDENCIES}"
  VERBATIM
  )

174

Rashad Kanavath's avatar
Rashad Kanavath committed
175
ExternalProject_Add(OTB
176 177
  DEPENDS ${OTB_DEPENDENCIES}
  PREFIX OTB
178
  DOWNLOAD_COMMAND ""
179 180 181 182 183
  SOURCE_DIR ${OTB_SB_SRC}
  BINARY_DIR ${OTB_SB_BUILD_DIR}
  INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
  DOWNLOAD_DIR ${DOWNLOAD_LOCATION}
  CMAKE_CACHE_ARGS
184
  ${SB_CMAKE_CACHE_ARGS}
185
  ${OTB_MODULES_CONFIG}
186 187 188
  -DBUILD_TESTING:BOOL=${BUILD_TESTING}
  -DBUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES}
  -DOTB_DATA_ROOT:STRING=${OTB_DATA_ROOT}
189 190
  -DOTB_DATA_USE_LARGEINPUT:BOOL=${OTB_DATA_USE_LARGEINPUT}
  -DOTB_DATA_LARGEINPUT_ROOT:PATH=${OTB_DATA_LARGEINPUT_ROOT}
191 192
  -DOTB_USE_6S:BOOL=${OTB_USE_6S}
  -DOTB_USE_CURL:BOOL=${OTB_USE_CURL}
193
  -DOTB_USE_LIBKML:BOOL=${OTB_USE_LIBKML}
194 195 196 197 198
  -DOTB_USE_LIBSVM:BOOL=${OTB_USE_LIBSVM}
  -DOTB_USE_MAPNIK:BOOL=${OTB_USE_MAPNIK}
  -DOTB_USE_MUPARSER:BOOL=${OTB_USE_MUPARSER}
  -DOTB_USE_MUPARSERX:BOOL=${OTB_USE_MUPARSERX}
  -DOTB_USE_OPENCV:BOOL=${OTB_USE_OPENCV}
199
  -DOTB_USE_SHARK:BOOL=${OTB_USE_SHARK}
200
  -DOTB_USE_QT:BOOL=${OTB_USE_QT}
201 202 203 204 205
  -DOTB_USE_SIFTFAST:BOOL=${OTB_USE_SIFTFAST}
  -DOTB_USE_OPENGL:BOOL=${OTB_USE_OPENGL}
  -DOTB_USE_GLEW:BOOL=${OTB_USE_GLEW}
  -DOTB_USE_GLFW:BOOL=${OTB_USE_GLFW}
  -DOTB_USE_GLUT:BOOL=${OTB_USE_GLUT}
206
  -DOTB_USE_QWT:BOOL=${OTB_USE_QWT}
207
  -DOTB_USE_OPENMP:BOOL=${OTB_USE_OPENMP}
208
  -DOTB_USE_GSL:BOOL=${OTB_USE_GSL}
209
  -DOTB_WRAP_PYTHON:BOOL=${OTB_WRAP_PYTHON}
210
  -DOTB_WRAP_PYTHON3:BOOL=${OTB_WRAP_PYTHON3}
211 212
  -DOTB_WRAP_JAVA:BOOL=${OTB_WRAP_JAVA}
  ${OTB_ADDITIONAL_CACHE}
213
  CMAKE_ARGS ${OTB_SB_CONFIG}
214
  CMAKE_COMMAND ${SB_CMAKE_COMMAND}
215
  LOG_CONFIGURE 1
216
  )
217 218


219 220
ExternalProject_Add_Step(
  OTB install_copyright
221 222 223 224 225
  COMMAND ${CMAKE_COMMAND} -E copy
  ${OTB_SB_SRC}/LICENSE ${CMAKE_INSTALL_PREFIX}/share/copyright/LICENSE

  COMMAND ${CMAKE_COMMAND} -E copy
  ${OTB_SB_SRC}/NOTICE ${CMAKE_INSTALL_PREFIX}/share/copyright/NOTICE
226 227 228 229 230 231
  
  COMMAND ${CMAKE_COMMAND}
  -E copy_directory
  ${CMAKE_SOURCE_DIR}/Copyright ${CMAKE_INSTALL_PREFIX}/share/copyright
  DEPENDEES install
  )