CPackFreeBSD.cmake 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. if(CMAKE_BINARY_DIR)
  4. message(FATAL_ERROR "CPackFreeBSD.cmake may only be used by CPack internally.")
  5. endif()
  6. if(NOT UNIX)
  7. message(FATAL_ERROR "CPackFreeBSD.cmake may only be used under UNIX.")
  8. endif()
  9. ###
  10. #
  11. # These bits are copied from the Debian packaging file; slightly modified.
  12. # They are used for filling in FreeBSD-packaging variables that can take
  13. # on values from elsewhere -- e.g. the package description may as well be
  14. # copied from Debian.
  15. #
  16. function(_cpack_freebsd_fallback_var OUTPUT_VAR_NAME)
  17. set(FALLBACK_VAR_NAMES ${ARGN})
  18. set(VALUE "${${OUTPUT_VAR_NAME}}")
  19. if(VALUE)
  20. return()
  21. endif()
  22. foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
  23. if(${variable_name})
  24. set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
  25. set(VALUE "${${variable_name}}")
  26. break()
  27. endif()
  28. endforeach()
  29. if(NOT VALUE)
  30. message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from any variable ${FALLBACK_VAR_NAMES}.")
  31. endif()
  32. endfunction()
  33. function(check_required_var VAR_NAME)
  34. if(NOT ${VAR_NAME})
  35. message(FATAL_ERROR "Variable ${VAR_NAME} is not set.")
  36. endif()
  37. endfunction()
  38. set(_cpack_freebsd_fallback_origin "misc/bogus")
  39. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_NAME"
  40. "CPACK_PACKAGE_NAME"
  41. "CMAKE_PROJECT_NAME"
  42. )
  43. set(_cpack_freebsd_fallback_www "http://example.com/?pkg=${CPACK_FREEBSD_PACKAGE_NAME}")
  44. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_COMMENT"
  45. "CPACK_PACKAGE_DESCRIPTION_SUMMARY"
  46. )
  47. # TODO: maybe read the PACKAGE_DESCRIPTION file for the longer
  48. # FreeBSD pkg-descr?
  49. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION"
  50. "CPACK_DEBIAN_PACKAGE_DESCRIPTION"
  51. "CPACK_PACKAGE_DESCRIPTION_SUMMARY"
  52. "PACKAGE_DESCRIPTION"
  53. )
  54. # There's really only one homepage for a project, so
  55. # re-use the Debian setting if it's there.
  56. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_WWW"
  57. "CMAKE_PROJECT_HOMEPAGE_URL"
  58. "CPACK_DEBIAN_PACKAGE_HOMEPAGE"
  59. "_cpack_freebsd_fallback_www"
  60. )
  61. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_VERSION"
  62. "CMAKE_PROJECT_VERSION"
  63. "${CMAKE_PROJECT_NAME}_VERSION"
  64. "PROJECT_VERSION"
  65. "CPACK_PACKAGE_VERSION"
  66. "CPACK_PACKAGE_VERSION"
  67. )
  68. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_MAINTAINER"
  69. "CPACK_PACKAGE_CONTACT"
  70. )
  71. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_LICENSE"
  72. "CPACK_RPM_PACKAGE_LICENSE"
  73. )
  74. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_ORIGIN"
  75. "_cpack_freebsd_fallback_origin"
  76. )
  77. if(NOT CPACK_FREEBSD_PACKAGE_CATEGORIES)
  78. string(REGEX REPLACE "/.*" "" CPACK_FREEBSD_PACKAGE_CATEGORIES ${CPACK_FREEBSD_PACKAGE_ORIGIN})
  79. endif()
  80. check_required_var("CPACK_FREEBSD_PACKAGE_NAME")
  81. check_required_var("CPACK_FREEBSD_PACKAGE_ORIGIN")
  82. check_required_var("CPACK_FREEBSD_PACKAGE_VERSION")
  83. check_required_var("CPACK_FREEBSD_PACKAGE_MAINTAINER")
  84. check_required_var("CPACK_FREEBSD_PACKAGE_COMMENT")
  85. check_required_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION")
  86. check_required_var("CPACK_FREEBSD_PACKAGE_WWW")
  87. check_required_var("CPACK_FREEBSD_PACKAGE_LICENSE")