CMakeLists.txt 4.2 KB

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