CMakeLists.txt 2.02 KB
Newer Older
1 2 3 4
#############################################################################
# Qt4 translations.
#----------------------------------------------------------------------------
# Locale human-readable translation files.
5
set( OTB_TS_TRANSLATIONS
6
# en_US.ts
7 8
  fr_FR.ts
)
9
unset(OTB_QM_TRANSLATIONS)
10 11

#----------------------------------------------------------------------------
12 13
# Configuration option to enable creation/merging of source .ts files
# Default value is: OFF.
14 15 16
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
17 18
  )

19
#----------------------------------------------------------------------------
20 21 22 23 24 25 26 27
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!"
      )

28
    message( STATUS "Qt I18N source files: ${OTB_QT_I18N_SOURCE_FILES}")
29

30 31
    set( OTB_QT_I18N_PRO "${CMAKE_CURRENT_BINARY_DIR}/i18n.pro" )

32
    generate_qt4_project( ${OTB_QT_I18N_PRO} )
33

34 35 36 37 38 39 40 41
    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
42 43 44
          ${OTB_QT_I18N_HEADER_FILES}
          ${OTB_QT_I18N_SOURCE_FILES}
          ${OTB_QT_I18N_FORM_FILES}
45 46 47 48
          ${OTB_QT_I18N_PRO}
        VERBATIM)
    endforeach()
  endif()
49

50
  qt4_add_translation(OTB_QM_TRANSLATIONS
51 52 53 54 55 56 57 58 59 60 61 62 63 64
      ${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()