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