OSX/cpack: add a dummy bg and ds_store for dmg
[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         include(FindGit)
25         if(GIT_FOUND)
26                 message(STATUS "-- Found Git: ${GIT_EXECUTABLE}")
27                 execute_process(COMMAND git rev-parse --short @{u}
28                                 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
29                                 OUTPUT_VARIABLE MY_WC_HASH
30                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
31         endif()
32 endif()
33 set(BUILD_REV ${MY_WC_HASH})
34 unset(MY_WC_HASH)
35
36
37 # Force Package Name
38 execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE CPACK_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
39 set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${CMAKE_SYSTEM_PROCESSOR})
40
41 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
42         # RPM packages
43         include(build_files/cmake/RpmBuild.cmake)
44         if(RPMBUILD_FOUND)
45                 set(CPACK_GENERATOR "RPM")
46                 set(CPACK_RPM_PACKAGE_RELEASE "git${CPACK_DATE}.${BUILD_REV}")
47                 set(CPACK_SET_DESTDIR "true")
48                 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
49                 set(CPACK_PACKAGE_RELOCATABLE "false")
50                 set(CPACK_RPM_PACKAGE_LICENSE "GPLv2+ and Apache 2.0")
51                 set(CPACK_RPM_PACKAGE_GROUP "Amusements/Multimedia")
52                 set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/build_files/package_spec/rpm/blender.spec.in")
53         endif()
54 endif()
55
56 # Mac Bundle
57 if(APPLE)
58         set(CPACK_GENERATOR "DragNDrop")
59
60         # Libraries are bundled directly
61         set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE)
62         set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/release/darwin/background.png")
63         set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/release/darwin/SET_DS_Store")
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_UI_BANNER ${LIBDIR}/package/installer_wix/WIX_UI_BANNER.bmp)
78         set(CPACK_WIX_UI_DIALOG ${LIBDIR}/package/installer_wix/WIX_UI_DIALOG.bmp)
79
80         #force lzma instead of deflate
81         set(CPACK_WIX_LIGHT_EXTRA_FLAGS -dcl:high)
82 endif()
83
84 set(CPACK_PACKAGE_EXECUTABLES "blender" "blender")
85 include(CPack)
86
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
93         add_custom_target(package_archive DEPENDS ${package_output})
94
95         add_custom_command(
96                 OUTPUT ${package_output}
97                 COMMAND ${build_archive} ${packagename} ${extension} bin release
98                 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
99         unset(build_archive)
100         unset(package_output)
101 endmacro()
102
103 if(APPLE)
104         add_package_archive(
105                 "${PROJECT_NAME}-${BLENDER_VERSION}-${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}"
106                 "zip")
107 elseif(UNIX)
108         # platform name could be tweaked, to include glibc, and ensure processor is correct (i386 vs i686)
109         string(TOLOWER ${CMAKE_SYSTEM_NAME} PACKAGE_SYSTEM_NAME)
110
111         add_package_archive(
112                 "${PROJECT_NAME}-${BLENDER_VERSION}-${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}"
113                 "tar.bz2")
114 endif()
115