packaging.cmake 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. string(TIMESTAMP CURRENT_YEAR "%Y")
  2. set(PROJECT_DESCRIPTION "Blender is the free and open source 3D creation suite software.")
  3. set(PROJECT_COPYRIGHT "Copyright (C) 2001-${CURRENT_YEAR} Blender Foundation")
  4. set(PROJECT_CONTACT "foundation@blender.org")
  5. set(PROJECT_VENDOR "Blender Foundation")
  6. set(MAJOR_VERSION ${BLENDER_VERSION_MAJOR})
  7. set(MINOR_VERSION ${BLENDER_VERSION_MINOR})
  8. set(PATCH_VERSION ${BLENDER_VERSION_CHAR_INDEX})
  9. set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
  10. set(CPACK_PACKAGE_DESCRIPTION ${PROJECT_DESCRIPTION})
  11. set(CPACK_PACKAGE_VENDOR ${PROJECT_VENDOR})
  12. set(CPACK_PACKAGE_CONTACT ${PROJECT_CONTACT})
  13. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
  14. set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
  15. SET(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
  16. SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
  17. SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
  18. # Get the build revision, note that this can get out-of-sync, so for packaging run cmake first.
  19. set(MY_WC_HASH "unknown")
  20. if(EXISTS ${CMAKE_SOURCE_DIR}/.git/)
  21. find_package(Git)
  22. if(GIT_FOUND)
  23. message(STATUS "Found Git: ${GIT_EXECUTABLE}")
  24. execute_process(COMMAND git rev-parse --short HEAD
  25. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  26. OUTPUT_VARIABLE MY_WC_HASH
  27. OUTPUT_STRIP_TRAILING_WHITESPACE
  28. ERROR_QUIET)
  29. endif()
  30. endif()
  31. set(BUILD_REV ${MY_WC_HASH})
  32. unset(MY_WC_HASH)
  33. # Force Package Name
  34. execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE CPACK_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
  35. string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
  36. if(MSVC)
  37. if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  38. set(PACKAGE_ARCH windows64)
  39. else()
  40. set(PACKAGE_ARCH windows32)
  41. endif()
  42. else(MSVC)
  43. set(PACKAGE_ARCH ${CMAKE_SYSTEM_PROCESSOR})
  44. endif()
  45. if(CPACK_OVERRIDE_PACKAGENAME)
  46. set(CPACK_PACKAGE_FILE_NAME ${CPACK_OVERRIDE_PACKAGENAME}-${PACKAGE_ARCH})
  47. else()
  48. set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME_LOWER}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${PACKAGE_ARCH})
  49. endif()
  50. if(CMAKE_SYSTEM_NAME MATCHES "Linux")
  51. # RPM packages
  52. include(build_files/cmake/RpmBuild.cmake)
  53. if(RPMBUILD_FOUND)
  54. set(CPACK_GENERATOR "RPM")
  55. set(CPACK_RPM_PACKAGE_RELEASE "git${CPACK_DATE}.${BUILD_REV}")
  56. set(CPACK_SET_DESTDIR "true")
  57. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
  58. set(CPACK_PACKAGE_RELOCATABLE "false")
  59. set(CPACK_RPM_PACKAGE_LICENSE "GPLv2+ and Apache 2.0")
  60. set(CPACK_RPM_PACKAGE_GROUP "Amusements/Multimedia")
  61. set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/build_files/package_spec/rpm/blender.spec.in")
  62. endif()
  63. endif()
  64. # Mac Bundle
  65. if(APPLE)
  66. set(CPACK_GENERATOR "DragNDrop")
  67. # Libraries are bundled directly
  68. set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE)
  69. endif()
  70. if(WIN32)
  71. set(CPACK_PACKAGE_INSTALL_DIRECTORY "Blender Foundation/Blender")
  72. set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "Blender Foundation/Blender")
  73. set(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.ico)
  74. set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
  75. set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt)
  76. set(CPACK_WIX_PRODUCT_ICON ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.ico)
  77. set(CPACK_WIX_UPGRADE_GUID "B767E4FD-7DE7-4094-B051-3AE62E13A17A")
  78. set(CPACK_WIX_TEMPLATE ${LIBDIR}/package/installer_wix/WIX.template)
  79. set(CPACK_WIX_UI_BANNER ${LIBDIR}/package/installer_wix/WIX_UI_BANNER.bmp)
  80. set(CPACK_WIX_UI_DIALOG ${LIBDIR}/package/installer_wix/WIX_UI_DIALOG.bmp)
  81. #force lzma instead of deflate
  82. set(CPACK_WIX_LIGHT_EXTRA_FLAGS -dcl:high)
  83. endif()
  84. set(CPACK_PACKAGE_EXECUTABLES "blender" "blender")
  85. set(CPACK_CREATE_DESKTOP_LINKS "blender" "blender")
  86. include(CPack)
  87. # Target for build_archive.py script, to automatically pass along
  88. # version, revision, platform, build directory
  89. macro(add_package_archive packagename extension)
  90. set(build_archive python ${CMAKE_SOURCE_DIR}/build_files/package_spec/build_archive.py)
  91. set(package_output ${CMAKE_BINARY_DIR}/release/${packagename}.${extension})
  92. add_custom_target(package_archive DEPENDS ${package_output})
  93. add_custom_command(
  94. OUTPUT ${package_output}
  95. COMMAND ${build_archive} ${packagename} ${extension} bin release
  96. WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
  97. unset(build_archive)
  98. unset(package_output)
  99. endmacro()
  100. if(APPLE)
  101. add_package_archive(
  102. "${PROJECT_NAME}-${BLENDER_VERSION}-${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}"
  103. "zip")
  104. elseif(UNIX)
  105. # platform name could be tweaked, to include glibc, and ensure processor is correct (i386 vs i686)
  106. string(TOLOWER ${CMAKE_SYSTEM_NAME} PACKAGE_SYSTEM_NAME)
  107. add_package_archive(
  108. "${PROJECT_NAME}-${BLENDER_VERSION}-${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}"
  109. "tar.bz2")
  110. endif()
  111. unset(MAJOR_VERSION)
  112. unset(MINOR_VERSION)
  113. unset(PATCH_VERSION)
  114. unset(BUILD_REV)