CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Copyright (c) 2022 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. project(cura)
  4. cmake_minimum_required(VERSION 3.18)
  5. include(GNUInstallDirs)
  6. list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
  7. set(URANIUM_DIR "${CMAKE_SOURCE_DIR}/../Uranium" CACHE PATH "The location of the Uranium repository")
  8. set(URANIUM_SCRIPTS_DIR "${URANIUM_DIR}/scripts" CACHE PATH "The location of the scripts directory of the Uranium repository")
  9. option(CURA_DEBUGMODE "Enable debug dialog and other debug features" OFF)
  10. if(CURA_DEBUGMODE)
  11. set(_cura_debugmode "ON")
  12. endif()
  13. option(GENERATE_TRANSLATIONS "Should the translations be generated?" ON)
  14. set(CURA_APP_NAME "cura" CACHE STRING "Short name of Cura, used for configuration folder")
  15. set(CURA_APP_DISPLAY_NAME "Ultimaker Cura" CACHE STRING "Display name of Cura")
  16. set(CURA_VERSION "master" CACHE STRING "Version name of Cura")
  17. set(CURA_BUILDTYPE "" CACHE STRING "Build type of Cura, eg. 'PPA'")
  18. set(CURA_CLOUD_API_ROOT "" CACHE STRING "Alternative Cura cloud API root")
  19. set(CURA_CLOUD_API_VERSION "" CACHE STRING "Alternative Cura cloud API version")
  20. set(CURA_CLOUD_ACCOUNT_API_ROOT "" CACHE STRING "Alternative Cura cloud account API version")
  21. set(CURA_MARKETPLACE_ROOT "" CACHE STRING "Alternative Marketplace location")
  22. set(CURA_DIGITAL_FACTORY_URL "" CACHE STRING "Alternative Digital Factory location")
  23. configure_file(${CMAKE_SOURCE_DIR}/com.ultimaker.cura.desktop.in ${CMAKE_BINARY_DIR}/com.ultimaker.cura.desktop @ONLY)
  24. configure_file(cura/CuraVersion.py.in CuraVersion.py @ONLY)
  25. if(NOT DEFINED Python_VERSION)
  26. set(Python_VERSION
  27. 3.10
  28. CACHE STRING "Python Version" FORCE)
  29. message(STATUS "Setting Python version to ${Python_VERSION}. Set Python_VERSION if you want to compile against an other version.")
  30. endif()
  31. if(APPLE)
  32. set(Python_FIND_FRAMEWORK NEVER)
  33. endif()
  34. find_package(Python ${Python_VERSION} EXACT REQUIRED COMPONENTS Interpreter)
  35. message(STATUS "Linking and building ${project_name} against Python ${Python_VERSION}")
  36. if(NOT DEFINED Python_SITELIB_LOCAL)
  37. set(Python_SITELIB_LOCAL
  38. "${Python_SITELIB}"
  39. CACHE PATH "Local alternative site-package location to install Cura" FORCE)
  40. endif()
  41. # Tests
  42. include(CuraTests)
  43. if(NOT ${URANIUM_DIR} STREQUAL "")
  44. set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${URANIUM_DIR}/cmake")
  45. endif()
  46. if(NOT ${URANIUM_SCRIPTS_DIR} STREQUAL "")
  47. list(APPEND CMAKE_MODULE_PATH ${URANIUM_DIR}/cmake)
  48. include(UraniumTranslationTools)
  49. # Extract Strings
  50. add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura)
  51. # Build Translations
  52. if(${GENERATE_TRANSLATIONS})
  53. CREATE_TRANSLATION_TARGETS()
  54. endif()
  55. endif()
  56. install(DIRECTORY resources DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
  57. include(CuraPluginInstall)
  58. install(FILES cura_app.py DESTINATION ${CMAKE_INSTALL_BINDIR}
  59. PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  60. install(DIRECTORY cura DESTINATION "${Python_SITELIB_LOCAL}")
  61. install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py DESTINATION "${Python_SITELIB_LOCAL}/cura/")
  62. if(NOT APPLE AND NOT WIN32)
  63. install(FILES ${CMAKE_BINARY_DIR}/com.ultimaker.cura.desktop
  64. DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  65. install(FILES ${CMAKE_SOURCE_DIR}/resources/images/cura-icon.png
  66. DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps/)
  67. install(FILES com.ultimaker.cura.appdata.xml
  68. DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
  69. install(FILES cura.sharedmimeinfo
  70. DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages/
  71. RENAME cura.xml )
  72. endif()