CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. set(CURA_VERSION "master" CACHE STRING "Version name of Cura")
  6. configure_file(cura/CuraVersion.py.in CuraVersion.py @ONLY)
  7. # Macro needed to list all sub-directory of a directory.
  8. # There is no function in cmake as far as I know.
  9. # Found at: http://stackoverflow.com/a/7788165
  10. MACRO(SUBDIRLIST result curdir)
  11. FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
  12. SET(dirlist "")
  13. FOREACH(child ${children})
  14. IF(IS_DIRECTORY ${curdir}/${child})
  15. LIST(APPEND dirlist ${child})
  16. ENDIF()
  17. ENDFOREACH()
  18. SET(${result} ${dirlist})
  19. ENDMACRO()
  20. if(NOT ${URANIUM_SCRIPTS_DIR} STREQUAL "")
  21. # Extract Strings
  22. add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura)
  23. # Build Translations
  24. find_package(Gettext)
  25. if(GETTEXT_FOUND)
  26. # translations target will convert .po files into .mo and .qm as needed.
  27. # The files are checked for a _qt suffix and if it is found, converted to
  28. # qm, otherwise they are converted to .po.
  29. add_custom_target(translations ALL)
  30. # copy-translations can be used to copy the built translation files from the
  31. # build directory to the source resources directory. This is mostly a convenience
  32. # during development, normally you want to simply use the install target to install
  33. # the files along side the rest of the application.
  34. SUBDIRLIST(languages ${CMAKE_SOURCE_DIR}/resources/i18n/)
  35. foreach(lang ${languages})
  36. file(GLOB po_files ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/*.po)
  37. foreach(po_file ${po_files})
  38. string(REGEX REPLACE ".*/(.*).po" "${CMAKE_BINARY_DIR}/resources/i18n/${lang}/LC_MESSAGES/\\1.mo" mo_file ${po_file})
  39. add_custom_command(TARGET translations POST_BUILD COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ARGS ${po_file} -o ${mo_file} -f)
  40. endforeach()
  41. endforeach()
  42. install(DIRECTORY ${CMAKE_BINARY_DIR}/resources
  43. DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  44. endif()
  45. endif()
  46. find_package(PythonInterp 3.4.0 REQUIRED)
  47. install(DIRECTORY resources
  48. DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  49. install(DIRECTORY plugins
  50. DESTINATION lib/cura)
  51. if(NOT APPLE AND NOT WIN32)
  52. install(FILES cura_app.py
  53. DESTINATION ${CMAKE_INSTALL_BINDIR}
  54. PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
  55. RENAME cura)
  56. install(DIRECTORY cura
  57. DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages
  58. FILES_MATCHING PATTERN *.py)
  59. install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py
  60. DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages/cura)
  61. install(FILES cura.desktop
  62. DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  63. install(FILES cura.sharedmimeinfo
  64. DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages/
  65. RENAME cura.xml )
  66. else()
  67. install(FILES cura_app.py
  68. DESTINATION ${CMAKE_INSTALL_BINDIR}
  69. PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  70. install(DIRECTORY cura
  71. DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages
  72. FILES_MATCHING PATTERN *.py)
  73. install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py
  74. DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/cura)
  75. endif()
  76. include(CPackConfig.cmake)