CMakeLists.txt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. SET(QT_LUPDATE_EXECUTABLE "${Qt5_LUPDATE_EXECUTABLE}")
  2. SET(QT_LRELEASE_EXECUTABLE "${Qt5_LRELEASE_EXECUTABLE}")
  3. IF(QT_LUPDATE_EXECUTABLE STREQUAL "")
  4. EXECUTE_PROCESS(COMMAND "lupdate" "-help" RESULT_VARIABLE LUPDATE_FALLBACK OUTPUT_QUIET)
  5. IF(LUPDATE_FALLBACK EQUAL 0)
  6. SET(QT_LUPDATE_EXECUTABLE lupdate)
  7. SET(QT_LRELEASE_EXECUTABLE lrelease)
  8. ELSE()
  9. MESSAGE(WARNING "Cannot generate locales")
  10. RETURN()
  11. ENDIF()
  12. ENDIF()
  13. #
  14. # rules for building localizations
  15. #
  16. SET(ts_targets "")
  17. SET(qm_targets "")
  18. SET(QM_FILES "")
  19. FILE(GLOB lmms_LOCALES ${CMAKE_CURRENT_SOURCE_DIR}/*.ts)
  20. LIST(SORT lmms_LOCALES)
  21. FOREACH(_ts_file ${lmms_LOCALES})
  22. GET_FILENAME_COMPONENT(_ts_target "${_ts_file}" NAME)
  23. STRING(REPLACE ".ts" ".qm" _qm_file "${_ts_file}")
  24. STRING(REPLACE ".ts" ".qm" _qm_target "${_ts_target}")
  25. ADD_CUSTOM_TARGET(${_ts_target}
  26. COMMAND "${QT_LUPDATE_EXECUTABLE}" -locations none -no-obsolete -I ${CMAKE_SOURCE_DIR}/include/ ${LMMS_SRCS} ${LMMS_UIS} ${CMAKE_SOURCE_DIR}/plugins -ts "\"${_ts_file}\""
  27. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  28. ADD_CUSTOM_TARGET(${_qm_target}
  29. COMMAND "${QT_LRELEASE_EXECUTABLE}" "${_ts_file}" -qm "${_qm_file}"
  30. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  31. LIST(APPEND ts_targets "${_ts_target}")
  32. LIST(APPEND qm_targets "${_qm_target}")
  33. LIST(APPEND QM_FILES "${_qm_file}")
  34. ENDFOREACH(_ts_file ${lmms_LOCALES})
  35. ADD_CUSTOM_TARGET(update-locales)
  36. FOREACH(_item ${ts_targets})
  37. ADD_DEPENDENCIES(update-locales "${_item}")
  38. ENDFOREACH(_item ${ts_targets})
  39. ADD_CUSTOM_TARGET(finalize-locales ALL)
  40. FOREACH(_item ${qm_targets})
  41. ADD_DEPENDENCIES(finalize-locales "${_item}")
  42. ENDFOREACH(_item ${qm_targets})
  43. IF(BUNDLE_QT_TRANSLATIONS)
  44. FILE(GLOB QT_QM_FILES "${QT_TRANSLATIONS_DIR}/qt*.qm")
  45. LIST(SORT QT_QM_FILES)
  46. ENDIF()
  47. INSTALL(FILES ${QM_FILES} ${QT_QM_FILES} DESTINATION "${LMMS_DATA_DIR}/locale")