CMakeLists.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. if(GETTEXT_FOUND)
  11. # translations target will convert .po files into .mo and .qm as needed.
  12. # The files are checked for a _qt suffix and if it is found, converted to
  13. # qm, otherwise they are converted to .po.
  14. add_custom_target(translations ALL)
  15. # copy-translations can be used to copy the built translation files from the
  16. # build directory to the source resources directory. This is mostly a convenience
  17. # during development, normally you want to simply use the install target to install
  18. # the files along side the rest of the application.
  19. add_custom_target(copy-translations)
  20. #TODO: Properly install the built files. This should be done after we move the applications out of the Uranium repo.
  21. set(languages
  22. en
  23. x-test
  24. ru
  25. fr
  26. de
  27. it
  28. es
  29. fi
  30. pl
  31. cs
  32. bg
  33. )
  34. foreach(lang ${languages})
  35. file(GLOB po_files resources/i18n/${lang}/*.po)
  36. foreach(file ${po_files})
  37. string(REGEX REPLACE ".*/(.*).po" "${lang}/\\1.mo" mofile ${file})
  38. add_custom_command(TARGET translations POST_BUILD COMMAND mkdir ARGS -p ${lang} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ARGS ${file} -o ${mofile})
  39. endforeach()
  40. file(GLOB mo_files ${CMAKE_BINARY_DIR}/${lang}/*.mo)
  41. foreach(file ${mo_files})
  42. 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}...")
  43. endforeach()
  44. install(FILES ${mo_files} DESTINATION ${CMAKE_INSTALL_DATADIR}/uranium/resources/i18n/${lang}/LC_MESSAGES/)
  45. endforeach()
  46. endif()
  47. endif()
  48. find_package(PythonInterp 3.4.0 REQUIRED)
  49. install(DIRECTORY resources DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  50. install(DIRECTORY plugins DESTINATION lib/cura)
  51. install(FILES cura_app.py DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  52. if(NOT APPLE AND NOT WIN32)
  53. install(DIRECTORY cura DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages)
  54. install(FILES cura.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  55. else()
  56. install(DIRECTORY cura DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
  57. endif()