CMakeLists.txt 3.8 KB

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