My CMake modules, scripts, templates
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FindGettextOverride.cmake 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. function(GETTEXT_PROCESS_PO_FILES _lang)
  2. set(_options ALL)
  3. set(_oneValueArgs INSTALL_DESTINATION)
  4. set(_multiValueArgs PO_FILES)
  5. set(_gmoFiles)
  6. CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
  7. foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
  8. get_filename_component(_name ${_current_PO_FILE} NAME)
  9. string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
  10. set(_basenameMAJOR ${_basename}-${MAJOR})
  11. set(installDIR ${CMAKE_BINARY_DIR}/share/locale/${_lang}/LC_MESSAGES)
  12. file(MAKE_DIRECTORY ${installDIR})
  13. set(_gmoFile ${installDIR}/${_basenameMAJOR}.mo)
  14. add_custom_command(OUTPUT ${_gmoFile}
  15. COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
  16. WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  17. DEPENDS ${_current_PO_FILE}
  18. )
  19. if(_parsedArguments_INSTALL_DESTINATION)
  20. install(FILES ${installDIR}/${_basenameMAJOR}.mo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/)
  21. endif()
  22. list(APPEND _gmoFiles ${_gmoFile})
  23. endforeach()
  24. if(NOT TARGET pofiles)
  25. add_custom_target(pofiles)
  26. endif()
  27. _GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName)
  28. if(_parsedArguments_ALL)
  29. add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
  30. else()
  31. add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
  32. endif()
  33. add_dependencies(pofiles ${uniqueTargetName})
  34. endfunction()