svn merge -r36583:36603 https://svn.blender.org/svnroot/bf-blender/trunk/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-2011 Blender Foundation")
3 set(PROJECT_CONTACT      "foundation@blender.org")
4 set(PROJECT_VENDOR       "Blender Foundation")
5 set(ORG_WEBSITE          "www.blender.org")
6
7 set(MAJOR_VERSION ${BLENDER_VERSION_MAJOR})
8 set(MINOR_VERSION ${BLENDER_VERSION_MINOR})
9 set(PATCH_VERSION ${BLENDER_VERSION_CHAR_INDEX})
10
11 set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
12 set(CPACK_PACKAGE_DESCRIPTION ${PROJECT_DESCRIPTION})
13 set(CPACK_PACKAGE_VENDOR ${PROJECT_VENDOR})
14 set(CPACK_PACKAGE_CONTACT ${PROJECT_CONTACT})
15 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
16 set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
17 SET(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
18 SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
19 SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
20
21
22 # Get the build revision, note that this can get out-of-sync, so for packaging run cmake first.
23 include(FindSubversion)
24 set(MY_WC_REVISION "unknown")
25 if(EXISTS ${CMAKE_SOURCE_DIR}/.svn/)
26         if(Subversion_FOUND)
27                 Subversion_WC_INFO(${CMAKE_SOURCE_DIR} MY)
28         endif()
29 endif()
30 set(BUILD_REV ${MY_WC_REVISION})
31
32
33 # Force Package Name
34 set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${BLENDER_VERSION}-r${BUILD_REV}-${CMAKE_SYSTEM_PROCESSOR})
35
36 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
37         # RPM packages
38         include(build_files/cmake/RpmBuild.cmake)
39         if(RPMBUILD_FOUND AND NOT WIN32)
40                 set(CPACK_GENERATOR "RPM")
41                 set(CPACK_RPM_PACKAGE_RELEASE "1.r${BUILD_REV}")
42                 set(CPACK_SET_DESTDIR "true")
43                 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
44                 set(CPACK_PACKAGE_RELOCATABLE "false")
45                 set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
46                 set(CPACK_RPM_PACKAGE_GROUP "Amusements/Graphics")
47                 set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/build_files/package_spec/rpm/blender.spec.in")
48         endif()
49 endif()
50
51 # Mac Bundle
52 if(APPLE)
53         set(CPACK_GENERATOR "DragNDrop")
54
55         # Libraries are bundled directly
56         set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE)
57 endif()
58
59 set(CPACK_PACKAGE_EXECUTABLES "blender")
60 include(CPack)
61
62 # Target for build_archive.py script, to automatically pass along
63 # version, revision, platform, build directory
64 macro(add_package_archive packagename extension)
65         set(build_archive python ${CMAKE_SOURCE_DIR}/build_files/package_spec/build_archive.py)
66         set(package_output ${CMAKE_BINARY_DIR}/release/${packagename}.${extension})
67
68         add_custom_target(package_archive DEPENDS ${package_output})
69
70         add_custom_command(
71                 OUTPUT ${package_output}
72                 COMMAND ${build_archive} ${packagename} ${extension} bin release
73                 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
74 endmacro()
75
76 if(APPLE)
77         add_package_archive(
78                 "blender-${BLENDER_VERSION}-r${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}"
79                 "zip")
80 elseif(UNIX)
81         # platform name could be tweaked, to include glibc, and ensure processor is correct (i386 vs i686)
82         string(TOLOWER ${CMAKE_SYSTEM_NAME} PACKAGE_SYSTEM_NAME)
83
84         add_package_archive(
85                 "blender-${BLENDER_VERSION}-r${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}"
86                 "tar.bz2")
87 endif()
88