CMakeLists.txt 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. project(cura)
  2. cmake_minimum_required(VERSION 2.8.12)
  3. include(GNUInstallDirs)
  4. set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY "The location of the scripts directory of the Uranium repository")
  5. if(NOT ${URANIUM_SCRIPTS_DIR} STREQUAL "")
  6. # Extract Strings
  7. add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura)
  8. # Build Translations
  9. find_package(Gettext)
  10. find_package(Qt5LinguistTools QUIET CONFIG)
  11. if(GETTEXT_FOUND AND Qt5LinguistTools_FOUND)
  12. include(${URANIUM_SCRIPTS_DIR}/ECMPoQmTools.cmake)
  13. # translations target will convert .po files into .mo and .qm as needed.
  14. # The files are checked for a _qt suffix and if it is found, converted to
  15. # qm, otherwise they are converted to .po.
  16. add_custom_target(translations ALL)
  17. # copy-translations can be used to copy the built translation files from the
  18. # build directory to the source resources directory. This is mostly a convenience
  19. # during development, normally you want to simply use the install target to install
  20. # the files along side the rest of the application.
  21. add_custom_target(copy-translations)
  22. #TODO: Properly install the built files. This should be done after we move the applications out of the Uranium repo.
  23. set(languages
  24. en
  25. x-test
  26. ru
  27. fr
  28. de
  29. it
  30. es
  31. fi
  32. )
  33. foreach(lang ${languages})
  34. file(GLOB po_files resources/i18n/${lang}/*.po)
  35. foreach(file ${po_files})
  36. string(REGEX MATCH "qt\\.po$" match "${file}")
  37. if(match)
  38. ecm_process_po_files_as_qm(${lang} PO_FILES ${file})
  39. else()
  40. string(REGEX REPLACE ".*/(.*).po" "${lang}/\\1.mo" mofile ${file})
  41. add_custom_command(TARGET translations POST_BUILD COMMAND mkdir ARGS -p ${lang} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ARGS ${file} -o ${mofile})
  42. endif()
  43. endforeach()
  44. file(GLOB qm_files ${CMAKE_BINARY_DIR}/${lang}/*.qm)
  45. file(GLOB mo_files ${CMAKE_BINARY_DIR}/${lang}/*.mo)
  46. foreach(file ${qm_files} ${mo_files})
  47. add_custom_command(TARGET copy-translations POST_BUILD COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMAND cp ARGS ${file} ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMENT "Copying ${file}...")
  48. endforeach()
  49. install(FILES ${qm_files} ${mo_files} DESTINATION ${CMAKE_INSTALL_DATADIR}/uranium/resources/i18n/${lang}/LC_MESSAGES/)
  50. endforeach()
  51. endif()
  52. endif()
  53. find_package(PythonInterp 3.4.0 REQUIRED)
  54. install(DIRECTORY resources DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  55. install(DIRECTORY plugins DESTINATION lib/cura)
  56. install(FILES cura_app.py DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  57. if(NOT APPLE AND NOT WIN32)
  58. install(DIRECTORY cura DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages)
  59. install(FILES cura.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  60. else()
  61. install(DIRECTORY cura DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
  62. endif()