CMakeLists.txt 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. project(cura)
  2. cmake_minimum_required(VERSION 2.8.12)
  3. set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY "The location of the scripts directory of the Uranium repository")
  4. if(${URANIUM_SCRIPTS_DIR})
  5. # Extract Strings
  6. add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura)
  7. # Build Translations
  8. find_package(Gettext)
  9. include(${URANIUM_SCRIPTS_DIR}/ECMPoQmTools.cmake)
  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)
  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. )
  25. foreach(lang ${languages})
  26. file(GLOB po_files resources/i18n/${lang}/*.po)
  27. foreach(file ${po_files})
  28. string(REGEX MATCH "qt\\.po$" match "${file}")
  29. if(match)
  30. ecm_process_po_files_as_qm(${lang} PO_FILES ${file})
  31. else()
  32. string(REGEX REPLACE ".*/(.*).po" "${lang}/\\1.mo" mofile ${file})
  33. add_custom_command(TARGET translations POST_BUILD COMMAND mkdir ARGS -p ${lang} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ARGS ${file} -o ${mofile})
  34. endif()
  35. endforeach()
  36. file(GLOB qm_files ${CMAKE_BINARY_DIR}/${lang}/*.qm)
  37. file(GLOB mo_files ${CMAKE_BINARY_DIR}/${lang}/*.mo)
  38. foreach(file ${qm_files} ${mo_files})
  39. 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}...")
  40. endforeach()
  41. endforeach()
  42. endif()
  43. endif()
  44. include(GNUInstallDirs)
  45. find_package(PythonInterp 3.4.0 REQUIRED)
  46. set(PYTHON_SITE_PACKAGES_DIR ${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages CACHE PATH "Install location of Python package")
  47. install(DIRECTORY resources DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  48. file(GLOB cura_plugins_SRCS plugins/*)
  49. install(DIRECTORY ${cura_plugins_SRCS} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cura)
  50. file(GLOB cura_SRCS src/*)
  51. install(FILES ${cura_SRCS} DESTINATION ${PYTHON_SITE_PACKAGES_DIR}/cura)
  52. install(FILES cura.py DESTINATION ${CMAKE_INSTALL_BINDIR})