CMakeLists.txt 3.9 KB

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