Windows Packaging : Make package-name confirm to the windows[32/64] naming scheme...
[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 if (MSVC)
42         if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
43                 set(PACKAGE_ARCH windows64)
44         else()
45                 set(PACKAGE_ARCH windows32)
46         endif()
47 else(MSVC)
48         set(PACKAGE_ARCH ${CMAKE_SYSTEM_PROCESSOR})
49 endif()
50
51 set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME_LOWER}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${PACKAGE_ARCH})
52
53 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
54         # RPM packages
55         include(build_files/cmake/RpmBuild.cmake)
56         if(RPMBUILD_FOUND)
57                 set(CPACK_GENERATOR "RPM")
58                 set(CPACK_RPM_PACKAGE_RELEASE "git${CPACK_DATE}.${BUILD_REV}")
59                 set(CPACK_SET_DESTDIR "true")
60                 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
61                 set(CPACK_PACKAGE_RELOCATABLE "false")
62                 set(CPACK_RPM_PACKAGE_LICENSE "GPLv2+ and Apache 2.0")
63                 set(CPACK_RPM_PACKAGE_GROUP "Amusements/Multimedia")
64                 set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/build_files/package_spec/rpm/blender.spec.in")
65         endif()
66 endif()
67
68 # Mac Bundle
69 if(APPLE)
70         set(CPACK_GENERATOR "DragNDrop")
71
72         # Libraries are bundled directly
73         set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE)
74 endif()
75
76 if(WIN32)
77         set(CPACK_PACKAGE_INSTALL_DIRECTORY "Blender Foundation/Blender")
78         set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "Blender Foundation/Blender")
79
80         set(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.ico)
81         set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
82
83         set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt)
84         set(CPACK_WIX_PRODUCT_ICON ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.ico)
85         set(CPACK_WIX_UPGRADE_GUID "B767E4FD-7DE7-4094-B051-3AE62E13A17A")
86
87         set(CPACK_WIX_TEMPLATE ${LIBDIR}/package/installer_wix/WIX.template)
88         set(CPACK_WIX_UI_BANNER ${LIBDIR}/package/installer_wix/WIX_UI_BANNER.bmp)
89         set(CPACK_WIX_UI_DIALOG ${LIBDIR}/package/installer_wix/WIX_UI_DIALOG.bmp)
90
91         #force lzma instead of deflate
92         set(CPACK_WIX_LIGHT_EXTRA_FLAGS -dcl:high)
93 endif()
94
95 set(CPACK_PACKAGE_EXECUTABLES "blender" "blender")
96 include(CPack)
97
98 # Target for build_archive.py script, to automatically pass along
99 # version, revision, platform, build directory
100 macro(add_package_archive packagename extension)
101         set(build_archive python ${CMAKE_SOURCE_DIR}/build_files/package_spec/build_archive.py)
102         set(package_output ${CMAKE_BINARY_DIR}/release/${packagename}.${extension})
103
104         add_custom_target(package_archive DEPENDS ${package_output})
105
106         add_custom_command(
107                 OUTPUT ${package_output}
108                 COMMAND ${build_archive} ${packagename} ${extension} bin release
109                 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
110         unset(build_archive)
111         unset(package_output)
112 endmacro()
113
114 if(APPLE)
115         add_package_archive(
116                 "${PROJECT_NAME}-${BLENDER_VERSION}-${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}"
117                 "zip")
118 elseif(UNIX)
119         # platform name could be tweaked, to include glibc, and ensure processor is correct (i386 vs i686)
120         string(TOLOWER ${CMAKE_SYSTEM_NAME} PACKAGE_SYSTEM_NAME)
121
122         add_package_archive(
123                 "${PROJECT_NAME}-${BLENDER_VERSION}-${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}"
124                 "tar.bz2")
125 endif()
126
127 unset(MAJOR_VERSION)
128 unset(MINOR_VERSION)
129 unset(PATCH_VERSION)
130
131 unset(BUILD_REV)
132