CMakeLists.txt 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  43. endif()
  44. endif()
  45. find_package(PythonInterp 3.4.0 REQUIRED)
  46. install(DIRECTORY resources DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  47. install(DIRECTORY plugins DESTINATION lib/cura)
  48. install(FILES cura_app.py DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  49. if(NOT APPLE AND NOT WIN32)
  50. install(DIRECTORY cura DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages FILES_MATCHING PATTERN *.py)
  51. install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages/cura)
  52. install(FILES cura.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  53. install(FILES cura.sharedmimeinfo
  54. DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages/
  55. RENAME cura.xml )
  56. else()
  57. install(DIRECTORY cura DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages FILES_MATCHING PATTERN *.py)
  58. install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/cura)
  59. endif()
  60. include(CPackConfig.cmake)