CMakeLists.txt 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 "2.1.2" 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. STRING(REPLACE "/" "" child ${child})
  16. LIST(APPEND dirlist ${child})
  17. ENDIF()
  18. ENDFOREACH()
  19. SET(${result} ${dirlist})
  20. ENDMACRO()
  21. if(NOT ${URANIUM_SCRIPTS_DIR} STREQUAL "")
  22. # Extract Strings
  23. add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura)
  24. # Build Translations
  25. find_package(Gettext)
  26. if(GETTEXT_FOUND)
  27. # translations target will convert .po files into .mo and .qm as needed.
  28. # The files are checked for a _qt suffix and if it is found, converted to
  29. # qm, otherwise they are converted to .po.
  30. add_custom_target(translations ALL)
  31. # copy-translations can be used to copy the built translation files from the
  32. # build directory to the source resources directory. This is mostly a convenience
  33. # during development, normally you want to simply use the install target to install
  34. # the files along side the rest of the application.
  35. SUBDIRLIST(languages ${CMAKE_SOURCE_DIR}/resources/i18n/)
  36. foreach(lang ${languages})
  37. file(GLOB po_files ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/*.po)
  38. foreach(po_file ${po_files})
  39. string(REGEX REPLACE ".*/(.*).po" "${CMAKE_BINARY_DIR}/resources/i18n/${lang}/LC_MESSAGES/\\1.mo" mo_file ${po_file})
  40. 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)
  41. endforeach()
  42. endforeach()
  43. install(DIRECTORY ${CMAKE_BINARY_DIR}/resources
  44. DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  45. endif()
  46. endif()
  47. find_package(PythonInterp 3.4.0 REQUIRED)
  48. install(DIRECTORY resources
  49. DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  50. install(DIRECTORY plugins
  51. DESTINATION lib/cura)
  52. if(NOT APPLE AND NOT WIN32)
  53. install(FILES cura_app.py
  54. DESTINATION ${CMAKE_INSTALL_BINDIR}
  55. PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
  56. RENAME cura)
  57. install(DIRECTORY cura
  58. DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages
  59. FILES_MATCHING PATTERN *.py)
  60. install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py
  61. DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages/cura)
  62. install(FILES cura.desktop
  63. DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  64. install(FILES cura.sharedmimeinfo
  65. DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages/
  66. RENAME cura.xml )
  67. else()
  68. install(FILES cura_app.py
  69. DESTINATION ${CMAKE_INSTALL_BINDIR}
  70. PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  71. install(DIRECTORY cura
  72. DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages
  73. FILES_MATCHING PATTERN *.py)
  74. install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py
  75. DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/cura)
  76. endif()
  77. include(CPackConfig.cmake)