2 # CPack script for creating Debian package
3 # Author: Mathieu Malaterre
5 # http://wiki.debian.org/HowToPackageForDebian
8 MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
9 ENDIF(CMAKE_BINARY_DIR)
12 MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
15 # Let's define the control file found in debian package:
18 # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
21 # debian policy enforce lower case for package name
22 # Package: (mandatory)
23 IF(NOT CPACK_DEBIAN_PACKAGE_NAME)
24 STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
25 ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME)
27 # Version: (mandatory)
28 IF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
29 IF(NOT CPACK_PACKAGE_VERSION)
30 MESSAGE(FATAL_ERROR "Debian package requires a package version")
31 ENDIF(NOT CPACK_PACKAGE_VERSION)
32 SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
33 ENDIF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
35 # Architecture: (mandatory)
36 IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
37 # There is no such thing as i686 architecture on debian, you should use i386 instead
38 # $ dpkg --print-architecture
39 FIND_PROGRAM(DPKG_CMD dpkg)
41 MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
42 SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
44 EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
45 OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
46 OUTPUT_STRIP_TRAILING_WHITESPACE
48 ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
50 # have a look at GET_PROPERTY(result GLOBAL PROPERTY ENABLED_FEATURES),
51 # this returns the successful FIND_PACKAGE() calls, maybe this can help
53 # You should set: DEBIAN_PACKAGE_DEPENDS
54 # TODO: automate 'objdump -p | grep NEEDED'
55 IF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
56 MESSAGE(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
57 ENDIF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
59 # Maintainer: (mandatory)
60 IF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
61 IF(NOT CPACK_PACKAGE_CONTACT)
62 MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
63 ENDIF(NOT CPACK_PACKAGE_CONTACT)
64 SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
65 ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
67 # Description: (mandatory)
68 IF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
69 IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
70 MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
71 ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
72 SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
73 ENDIF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
75 # Section: (recommended)
76 IF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
77 SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
78 ENDIF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
80 # Priority: (recommended)
81 IF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
82 SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
83 ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY )
86 # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
89 # You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
91 # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
92 # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
93 # Typical examples are:
99 # SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
100 # "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
103 # For debian source packages:
105 # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
108 # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
111 #IF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
112 # SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
113 # "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
115 #ENDIF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)