prepare_file_list.cmake 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#
# 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.
#
20
function(prepare_file_list file_list_result)
21

22
  set(file_list)
23
  set(otbapp_launcher "otbApplicationLauncherCommandLine${EXE_EXT}")
24
  #This must exist in any OTB Installation. minimal or full
25
  if(NOT EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${otbapp_launcher}")
26 27
    message(
      FATAL_ERROR
28
      "${SUPERBUILD_INSTALL_DIR}/bin/${otbapp_launcher} not found.")
29 30 31
    return()
  endif()

32 33 34 35 36 37 38
  # find OTB targets
  set(_otb_targets_path
    "${SUPERBUILD_INSTALL_DIR}/lib/cmake/OTB-${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}")
  file(GLOB _targets_config_files "${_otb_targets_path}/OTBTargets-*.cmake")
  set(_IMPORT_PREFIX ${SUPERBUILD_INSTALL_DIR})
  foreach(f ${_targets_config_files})
    file(STRINGS ${f} _f_content REGEX " IMPORTED_LOCATION_[A-Z]+ ")
Guillaume Pasero's avatar
Guillaume Pasero committed
39
    string(REGEX REPLACE " +IMPORTED_LOCATION_[A-Z]+ \"([^\"]+)\"" "\\1;" _filtered ${_f_content})
40 41 42
    string(CONFIGURE "${_filtered}" _configured)
    list(APPEND file_list "${_configured}")
  endforeach()
43

Rashad Kanavath's avatar
Rashad Kanavath committed
44
  if(HAVE_PYTHON)
45
    list(APPEND file_list "_otbApplication${PYMODULE_EXT}")
46
  endif()
Rashad Kanavath's avatar
Rashad Kanavath committed
47
  
48
  foreach(exe_file "SharkVersion")
Rashad Kanavath's avatar
Rashad Kanavath committed
49
    if(EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${exe_file}${EXE_EXT}")
Rashad Kanavath's avatar
Rashad Kanavath committed
50
      list(APPEND file_list "${exe_file}${EXE_EXT}")
51
    else()
Rashad Kanavath's avatar
Rashad Kanavath committed
52
      message(STATUS "${exe_file}${EXE_EXT} not found in ${SUPERBUILD_INSTALL_DIR}/bin. (skipping)")
53 54 55 56
    endif()
  endforeach()

  #Qt stuff
57
  if(HAVE_QT)
58
    list(APPEND file_list "lrelease${EXE_EXT}")
59 60
    list(APPEND file_list "lupdate${EXE_EXT}")
    list(APPEND file_list "lconvert${EXE_EXT}")
61 62 63 64 65 66
    list(APPEND file_list "moc${EXE_EXT}")
    list(APPEND file_list "qmake${EXE_EXT}")
    list(APPEND file_list "rcc${EXE_EXT}")
    list(APPEND file_list "uic${EXE_EXT}")
    list(APPEND file_list "proj${EXE_EXT}")
    list(APPEND file_list "cs2cs${EXE_EXT}")
67 68
  endif()
  
Rashad Kanavath's avatar
Rashad Kanavath committed
69 70 71 72
  file(GLOB otb_test_exe_list 
    "${SUPERBUILD_INSTALL_DIR}/bin/gdal*${EXE_EXT}"
    "${OTB_BINARY_DIR}/bin/*[T|t]est*${EXE_EXT}"
    )
73

Rashad Kanavath's avatar
Rashad Kanavath committed
74 75 76 77 78 79 80 81 82 83 84
  #special items to be removed!. hackety-hack
  list(REMOVE_ITEM otb_test_exe_list
    "${SUPERBUILD_INSTALL_DIR}/bin/gdal-config"
    )
  list(REMOVE_ITEM otb_test_exe_list
    "${OTB_BINARY_DIR}/bin/otbcli_TestApplication")
  
  list(REMOVE_ITEM otb_test_exe_list
    "${OTB_BINARY_DIR}/bin/otbgui_TestApplication")
  
  foreach(otb_test_exe   ${otb_test_exe_list})
85 86 87 88 89 90
    # filter .py files
    get_filename_component(otb_test_exe_ext ${otb_test_exe} EXT)
    if (NOT otb_test_exe_ext STREQUAL ".py")
      get_filename_component(otb_test_exe_name ${otb_test_exe} NAME)
      list(APPEND file_list ${otb_test_exe_name})
    endif()
Rashad Kanavath's avatar
Rashad Kanavath committed
91
  endforeach()
Guillaume Pasero's avatar
Guillaume Pasero committed
92 93 94 95 96 97 98 99 100 101 102

  # find ITK targets
  set(_itk_targets_path
    "${SUPERBUILD_INSTALL_DIR}/lib/cmake/ITK-${PKG_ITK_SB_VERSION}")
  file(GLOB _itk_targets_config_files "${_itk_targets_path}/ITKTargets-*.cmake")
  foreach(f ${_itk_targets_config_files})
    file(STRINGS ${f} _f_content REGEX " IMPORTED_LOCATION_[A-Z]+ ")
    string(REGEX REPLACE " +IMPORTED_LOCATION_[A-Z]+ \"([^\"]+)\"" "\\1;" _filtered ${_f_content})
    string(CONFIGURE "${_filtered}" _configured)
    list(APPEND file_list "${_configured}")
  endforeach()
Rashad Kanavath's avatar
Rashad Kanavath committed
103 104 105
  
  # special case for msvc: ucrtbase.dll must be explicitly vetted.
  # for proj.dll, see Mantis-1424
106
  # libEGL needed by Qt 5 at runtime
Rashad Kanavath's avatar
Rashad Kanavath committed
107 108 109
  if(MSVC)
    list(APPEND file_list "ucrtbase.dll")
    list(APPEND file_list "proj.dll")
110
  endif()
111

112 113 114 115 116 117 118
  # Qt plugins
  if(HAVE_QT)
    file(GLOB _qt_plugins "${SUPERBUILD_INSTALL_DIR}/plugins/*/${LIB_PREFIX}*${LIB_EXT}")
    foreach(_qt_plugin ${_qt_plugins})
      get_filename_component(_qt_plugin_name ${_qt_plugin} NAME)
      list(APPEND file_list ${_qt_plugin_name})
    endforeach()
119
  endif()
120

Rashad Kanavath's avatar
Rashad Kanavath committed
121
  set(${file_list_result} ${file_list} PARENT_SCOPE)
Rashad Kanavath's avatar
Rashad Kanavath committed
122
endfunction()