CMakeLists.txt 2.7 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 22 23 24
#############################################################################
# Qt4 translations.
#----------------------------------------------------------------------------
# Locale human-readable translation files.
25
set( OTB_TS_TRANSLATIONS
26
# en_US.ts
27 28
  fr_FR.ts
)
29
unset(OTB_QM_TRANSLATIONS)
30 31

#----------------------------------------------------------------------------
32 33
# Configuration option to enable creation/merging of source .ts files
# Default value is: OFF.
34 35 36
option( OTB_I18N_MERGE_TS
  "Create/merge .ts source translation files. WARNING: If ON, 'make clean' will delete the .ts files from source directory!"
  OFF
37 38
  )

39
#----------------------------------------------------------------------------
40 41 42 43 44 45 46 47
if( OTBQt4_ENABLED )
  # Generate commands to build Qt translations according to option.
  if( OTB_I18N_MERGE_TS )
    message(
      AUTHOR_WARNING
      "WARNING: OTB_I18N_MERGE_TS:BOOL option is set to ON. 'make clean' will delete .ts files from source directory!"
      )

48
    message( STATUS "Qt I18N source files: ${OTB_QT_I18N_SOURCE_FILES}")
49

50 51
    set( OTB_QT_I18N_PRO "${CMAKE_CURRENT_BINARY_DIR}/i18n.pro" )

52
    generate_qt4_project( ${OTB_QT_I18N_PRO} )
53

54 55 56 57 58 59 60 61
    foreach(_ts_name ${OTB_TS_TRANSLATIONS})
      get_filename_component(_abs_ts ${_ts_name} ABSOLUTE)

      message( STATUS "Merge TS : ${_abs_ts}")
      add_custom_command(OUTPUT ${_abs_ts}
        COMMAND ${QT_LUPDATE_EXECUTABLE}
        ARGS -locations none -pro ${OTB_QT_I18N_PRO} -ts ${_abs_ts}
        DEPENDS
62 63 64
          ${OTB_QT_I18N_HEADER_FILES}
          ${OTB_QT_I18N_SOURCE_FILES}
          ${OTB_QT_I18N_FORM_FILES}
65 66 67 68
          ${OTB_QT_I18N_PRO}
        VERBATIM)
    endforeach()
  endif()
69

70
  qt5_add_translation(OTB_QM_TRANSLATIONS
71 72 73 74 75 76 77 78 79 80 81 82 83 84
      ${OTB_TS_TRANSLATIONS}
      )

  # Custom build targets.
  add_custom_target( i18n ALL DEPENDS i18n_qt )
  add_custom_target( i18n_qt DEPENDS ${OTB_QM_TRANSLATIONS} )

  # Locale human-readable translation files.
  install(
    FILES ${OTB_QM_TRANSLATIONS}
    DESTINATION ${OTB_INSTALL_DATA_DIR}/i18n
    COMPONENT Resources
    )
endif()