CPackDeb.cmake 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # CPack script for creating Debian package
  2. # Author: Mathieu Malaterre
  3. #
  4. # http://wiki.debian.org/HowToPackageForDebian
  5. IF(CMAKE_BINARY_DIR)
  6. MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
  7. ENDIF(CMAKE_BINARY_DIR)
  8. IF(NOT UNIX)
  9. MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
  10. ENDIF(NOT UNIX)
  11. FIND_PROGRAM(AR_EXECUTABLE ar)
  12. IF(NOT AR_EXECUTABLE)
  13. # Is there a *NIX out there without ar ?
  14. MESSAGE(FATAL_ERROR "Debian package requires ar executable")
  15. ENDIF(NOT AR_EXECUTABLE)
  16. # Let's define the control file found in debian package:
  17. # Binary package:
  18. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
  19. # DEBIAN/control
  20. # debian policy enforce lower case for package name
  21. # Package: (mandatory)
  22. IF(NOT DEBIAN_PACKAGE_NAME)
  23. STRING(TOLOWER "${CPACK_PACKAGE_NAME}" DEBIAN_PACKAGE_NAME)
  24. ENDIF(NOT DEBIAN_PACKAGE_NAME)
  25. # Version: (mandatory)
  26. IF(NOT DEBIAN_PACKAGE_VERSION)
  27. IF(NOT CPACK_PACKAGE_VERSION)
  28. MESSAGE(FATAL_ERROR "Debian package requires a package version")
  29. ENDIF(NOT CPACK_PACKAGE_VERSION)
  30. SET(DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
  31. ENDIF(NOT DEBIAN_PACKAGE_VERSION)
  32. # Architecture: (mandatory)
  33. IF(NOT DEBIAN_PACKAGE_ARCHITECTURE)
  34. # There is no such thing as i686 architecture on debian, you should use i386 instead
  35. # $ dpkg --print-architecture
  36. SET(DEBIAN_PACKAGE_ARCHITECTURE i386)
  37. ENDIF(NOT DEBIAN_PACAKGE_ARCHITECTURE)
  38. # have a look at GET_PROPERTY(result GLOBAL ENABLED_FEATURES), this returns
  39. # the successful FIND_PACKAGE() calls, maybe this can help
  40. # Depends:
  41. IF(NOT DEBIAN_PACKAGE_DEPENDS)
  42. MESSAGE(STATUS "DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
  43. ENDIF(NOT DEBIAN_PACKAGE_DEPENDS)
  44. # Maintainer: (mandatory)
  45. IF(NOT DEBIAN_PACKAGE_MAINTAINER)
  46. IF(NOT CPACK_PACKAGE_CONTACT)
  47. MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or DEBIAN_PACKAGE_MAINTAINER")
  48. ENDIF(NOT CPACK_PACKAGE_CONTACT)
  49. SET(DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
  50. ENDIF(NOT DEBIAN_PACKAGE_MAINTAINER)
  51. # Description: (mandatory)
  52. IF(NOT DEBIAN_PACKAGE_DESCRIPTION)
  53. IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
  54. MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or DEBIAN_PACKAGE_DESCRIPTION")
  55. ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
  56. SET(DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  57. ENDIF(NOT DEBIAN_PACKAGE_DESCRIPTION)
  58. # Section: (recommended)
  59. IF(NOT DEBIAN_PACKAGE_SECTION)
  60. SET(DEBIAN_PACKAGE_SECTION "devel")
  61. ENDIF(NOT DEBIAN_PACKAGE_SECTION)
  62. # Priority: (recommended)
  63. IF(NOT DEBIAN_PACKAGE_PRIORITY)
  64. SET(DEBIAN_PACKAGE_PRIORITY "optional")
  65. ENDIF(NOT DEBIAN_PACKAGE_PRIORITY )
  66. # Recommends:
  67. # You should set: DEBIAN_PACKAGE_RECOMMENDS
  68. # Suggests:
  69. # You should set: DEBIAN_PACKAGE_SUGGESTS
  70. # For debian source packages:
  71. # debian/control
  72. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
  73. # .dsc
  74. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
  75. # Builds-Depends:
  76. #IF(NOT DEBIAN_PACKAGE_BUILDS_DEPENDS)
  77. # SET(DEBIAN_PACKAGE_BUILDS_DEPENDS
  78. # "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
  79. # )
  80. #ENDIF(NOT DEBIAN_PACKAGE_BUILDS_DEPENDS)