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