i18n_qt.cmake 3.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#
# 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.
#

#
# Reset Qt I18N source files cache variable.
23
macro( reset_qt_i18n_sources )
24 25 26 27 28 29 30 31 32 33 34 35
  set( OTB_QT_I18N_INCLUDE_PATH "" CACHE INTERNAL "" FORCE )
  set( OTB_QT_I18N_HEADER_FILES "" CACHE INTERNAL "" FORCE )
  set( OTB_QT_I18N_SOURCE_FILES "" CACHE INTERNAL "" FORCE )
  set( OTB_QT_I18N_FORM_FILES "" CACHE INTERNAL "" FORCE )
endmacro()

# string( REPLACE ".cxx" ".h" OTB_QT_I18N_HEADER_FILES OTB_QT_I18N_SOURCE_FILES )

# string( REPLACE ".cxx" ".ui" OTB_QT_I18N_HEADER_FILES OTB_QT_I18N_SOURCE_FILES )

#
# Func
36
function( add_to_qt_i18n_files RESULT )
37 38 39 40 41 42 43 44 45 46 47
  foreach( F ${ARGN} )
    #message( "${F}" )

    get_filename_component( ABS_FILE ${F} ABSOLUTE )

    set(${RESULT} ${${RESULT}} ${ABS_FILE} CACHE INTERNAL "")
  endforeach()
endfunction()

#
#
48
macro( add_to_qt_i18n_include_path DIRECTORY )
49 50 51 52 53
  set(OTB_I18N_INCLUDE_PATH ${OTB_I18N_INCLUDE_PATH} ${DIRECTORY} CACHE INTERNAL "")
endmacro()

#
#
54
macro( add_to_qt_i18n_headers INCLUDE_DIR )
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

  get_filename_component( ABS_INCLUDE_DIR ${INCLUDE_DIR} ABSOLUTE )

  set(OTB_QT_I18N_INCLUDE_PATH ${OTB_QT_I18N_INCLUDE_PATH} ${ABS_INCLUDE_DIR} CACHE INTERNAL "")

  foreach( F ${ARGN} )
    string( REPLACE ".cxx" ".h" HEADER ${F} )
    set( ABS_HEADER "${ABS_INCLUDE_DIR}/${HEADER}" )
    if(EXISTS ${ABS_HEADER})
      set(OTB_QT_I18N_HEADER_FILES ${OTB_QT_I18N_HEADER_FILES} ${ABS_HEADER} CACHE INTERNAL "")
    endif()
  endforeach()
endmacro()

#
# Add source files to Qt I18n translation build.
71 72
macro( add_to_qt_i18n_sources )
  add_to_qt_i18n_files( OTB_QT_I18N_SOURCE_FILES ${ARGN} )
73 74 75 76
endmacro()

#
# Add source files to Qt I18n translation build.
77 78
macro( add_to_qt_i18n_forms )
  add_to_qt_i18n_files( OTB_QT_I18N_FORM_FILES ${ARGN} )
79 80 81 82
endmacro()

#
#
83
macro( generate_qt_project FILENAME )
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
  message( STATUS "Generating Qt5 '${FILENAME}' project file for I18N." )

  unset(_OTB_QT_I18N_INCLUDE_PATH_PRO)
  unset(_OTB_QT_I18N_HEADER_PRO)
  unset(_OTB_QT_I18N_SOURCE_PRO)
  unset(_OTB_QT_I18N_FORM_PRO)
  foreach(_path ${OTB_QT_I18N_INCLUDE_PATH})
    set(_OTB_QT_I18N_INCLUDE_PATH_PRO
      "${_OTB_QT_I18N_INCLUDE_PATH_PRO} \"${_path}\"")
  endforeach()
  foreach(_file ${OTB_QT_I18N_HEADER_FILES})
    set(_OTB_QT_I18N_HEADER_PRO
      "${_OTB_QT_I18N_HEADER_PRO} \"${_file}\"")
  endforeach()
  foreach(_file ${OTB_QT_I18N_SOURCE_FILES})
    set(_OTB_QT_I18N_SOURCE_PRO
      "${_OTB_QT_I18N_SOURCE_PRO} \"${_file}\"")
  endforeach()
  foreach(_file ${OTB_QT_I18N_FORM_FILES})
    set(_OTB_QT_I18N_FORM_PRO
      "${_OTB_QT_I18N_FORM_PRO} \"${_file}\"")
  endforeach()

  file( WRITE
    ${FILENAME}

    "# OTB autogenerated .pro file needed to generate Qt I18N translations

INCLUDEPATH = ${_OTB_QT_I18N_INCLUDE_PATH_PRO}

HEADERS = ${_OTB_QT_I18N_HEADER_PRO}

SOURCES = ${_OTB_QT_I18N_SOURCE_PRO}

FORMS = ${_OTB_QT_I18N_FORM_PRO}
"
    )
endmacro()