diff options
author | Brad King <brad.king@kitware.com> | 2017-06-12 14:18:37 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-06-12 14:21:42 (GMT) |
commit | 0cb8730c0b4e032db451789933ee7eb65d264278 (patch) | |
tree | 6d654ebb396e1153b91f36b28f80b9ed41d7f329 /Modules | |
parent | 99153a9eb6c3e997dfb07dcf9ea01836f2c384d1 (diff) | |
parent | 2042cae9a5d9bb2f71a715022a4b6a7416c8e9e3 (diff) | |
download | CMake-0cb8730c0b4e032db451789933ee7eb65d264278.zip CMake-0cb8730c0b4e032db451789933ee7eb65d264278.tar.gz CMake-0cb8730c0b4e032db451789933ee7eb65d264278.tar.bz2 |
Merge topic 'cpack-freebsd-pkg'
2042cae9 CPack-FreeBSD: add a generator for FreeBSD pkg(8)
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !693
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CPack.cmake | 3 | ||||
-rw-r--r-- | Modules/CPackFreeBSD.cmake | 246 |
2 files changed, 249 insertions, 0 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index a63fc83..3915943 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -471,6 +471,7 @@ if(NOT CPACK_GENERATOR) option(CPACK_BINARY_TZ "Enable to build TZ packages" ON) endif() option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF) + option(CPACK_BINARY_FREEBSD "Enable to build FreeBSD packages" OFF) option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF) option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF) option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON) @@ -491,6 +492,7 @@ if(NOT CPACK_GENERATOR) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DEB DEB) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DRAGNDROP DragNDrop) + cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_FREEBSD FREEBSD) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_IFW IFW) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11) @@ -542,6 +544,7 @@ mark_as_advanced( CPACK_BINARY_CYGWIN CPACK_BINARY_DEB CPACK_BINARY_DRAGNDROP + CPACK_BINARY_FREEBSD CPACK_BINARY_IFW CPACK_BINARY_NSIS CPACK_BINARY_OSXX11 diff --git a/Modules/CPackFreeBSD.cmake b/Modules/CPackFreeBSD.cmake new file mode 100644 index 0000000..7fec78a --- /dev/null +++ b/Modules/CPackFreeBSD.cmake @@ -0,0 +1,246 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CPackFreeBSD +------------ + +The built in (binary) CPack FreeBSD (pkg) generator (Unix only) + +Variables specific to CPack FreeBSD (pkg) generator +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +CPackFreeBSD may be used to create pkg(8) packages -- these may be used +on FreeBSD, DragonflyBSD, NetBSD, OpenBSD, but also on Linux or OSX, +depending on the installed package-management tools -- using :module:`CPack`. + +CPackFreeBSD is a :module:`CPack` generator and uses the ``CPACK_XXX`` +variables used by :module:`CPack`. It tries to re-use packaging information +that may already be specified for Debian packages for the :module:`CPackDeb` +generator. it also tries to re-use RPM packaging information when Debian +does not specify. + +CPackFreeBSD generator should work on any host with libpkg installed. The +packages it produces are specific to the host architecture and ABI. + +CPackFreeBSD sets package-metadata through :code:`CPACK_FREEBSD_XXX` variables. +CPackFreeBSD, unlike CPackDeb, does not specially support componentized +packages; a single package is created from all the software artifacts +created through CMake. + +All of the variables can be set specifically for FreeBSD packaging in +the CPackConfig file or in CMakeLists.txt, but most of them have defaults +that use general settings (e.g. CMAKE_PROJECT_NAME) or Debian-specific +variables when those make sense (e.g. the homepage of an upstream project +is usually unchanged by the flavor of packaging). When there is no Debian +information to fall back on, but the RPM packaging has it, fall back to +the RPM information (e.g. package license). + +.. variable:: CPACK_FREEBSD_PACKAGE_NAME + + Sets the package name (in the package manifest, but also affects the + output filename). + + * Mandatory: YES + * Default: + + - :variable:`CPACK_PACKAGE_NAME` (this is always set by CPack itself, + based on CMAKE_PROJECT_NAME). + +.. variable:: CPACK_FREEBSD_PACKAGE_COMMENT + + Sets the package comment. This is the short description displayed by + pkg(8) in standard "pkg info" output. + + * Mandatory: YES + * Default: + + - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` (this is always set + by CPack itself, if nothing else sets it explicitly). + - :variable:`PROJECT_DESCRIPTION` (this can be set with the DESCRIPTION + parameter for :command:`project`). + +.. variable:: CPACK_FREEBSD_PACKAGE_DESCRIPTION + + Sets the package description. This is the long description of the package, + given by "pkg info" with a specific package as argument. + + * Mandatory: YES + * Default: + + - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` (this may be set already + for Debian packaging, so we may as well re-use it). + +.. variable:: CPACK_FREEBSD_PACKAGE_WWW + + The URL of the web site for this package, preferably (when applicable) the + site from which the original source can be obtained and any additional + upstream documentation or information may be found. + + * Mandatory: YES + * Default: + + - :variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already + for Debian packaging, so we may as well re-use it). + +.. variable:: CPACK_FREEBSD_PACKAGE_LICENSE + + The license, or licenses, which apply to this software package. This must + be one or more license-identifiers that pkg recognizes as acceptable license + identifiers (e.g. "GPLv2"). + + * Mandatory: YES + * Default: + + - :variable:`CPACK_RPM_PACKAGE_LICENSE` + +.. variable:: CPACK_FREEBSD_PACKAGE_LICENSE_LOGIC + + This variable is only of importance if there is more than one license. + The default is "single", which is only applicable to a single license. + Other acceptable values are determined by pkg -- those are "dual" or "multi" -- + meaning choice (OR) or simultaneous (AND) application of the licenses. + + * Mandatory: NO + * Default: single + +.. variable:: CPACK_FREEBSD_PACKAGE_MAINTAINER + + The FreeBSD maintainer (e.g. kde@freebsd.org) of this package. + + * Mandatory: YES + * Default: none + +.. variable:: CPACK_FREEBSD_PACKAGE_ORIGIN + + The origin (ports label) of this package; for packages built by CPack + outside of the ports system this is of less importance. The default + puts the package somewhere under misc/, as a stopgap. + + * Mandatory: YES + * Default: misc/<package name> + +.. variable:: CPACK_FREEBSD_PACKAGE_CATEGORIES + + The ports categories where this package lives (if it were to be built + from ports). If none is set a single category is determined based on + the package origin. + + * Mandatory: YES + * Default: derived from ORIGIN + +.. variable:: CPACK_FREEBSD_PACKAGE_DEPS + + A list of package origins that should be added as package dependencies. + These are in the form <category>/<packagename>, e.g. x11/libkonq. + No version information needs to be provided (this is not included + in the manifest). + + * Mandatory: NO + * Default: empty +#]=======================================================================] + + + +if(CMAKE_BINARY_DIR) + message(FATAL_ERROR "CPackFreeBSD.cmake may only be used by CPack internally.") +endif() + +if(NOT UNIX) + message(FATAL_ERROR "CPackFreeBSD.cmake may only be used under UNIX.") +endif() + + +### +# +# These bits are copied from the Debian packaging file; slightly modified. +# They are used for filling in FreeBSD-packaging variables that can take +# on values from elsewhere -- e.g. the package description may as well be +# copied from Debian. +# +function(_cpack_freebsd_fallback_var OUTPUT_VAR_NAME) + set(FALLBACK_VAR_NAMES ${ARGN}) + + set(VALUE "${${OUTPUT_VAR_NAME}}") + if(VALUE) + return() + endif() + + foreach(variable_name IN LISTS FALLBACK_VAR_NAMES) + if(${variable_name}) + set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE) + set(VALUE "${${variable_name}}") + break() + endif() + endforeach() + if(NOT VALUE) + message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from any variable ${FALLBACK_VAR_NAMES}.") + endif() +endfunction() + +function(check_required_var VAR_NAME) + if(NOT ${VAR_NAME}) + message(FATAL_ERROR "Variable ${VAR_NAME} is not set.") + endif() +endfunction() + +set(_cpack_freebsd_fallback_origin "misc/bogus") + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_NAME" + "CPACK_PACKAGE_NAME" + "CMAKE_PROJECT_NAME" + ) + +set(_cpack_freebsd_fallback_www "http://example.com/?pkg=${CPACK_FREEBSD_PACKAGE_NAME}") + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_COMMENT" + "CPACK_PACKAGE_DESCRIPTION_SUMMARY" + ) + +# TODO: maybe read the PACKAGE_DESCRIPTION file for the longer +# FreeBSD pkg-descr? +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION" + "CPACK_DEBIAN_PACKAGE_DESCRIPTION" + "CPACK_PACKAGE_DESCRIPTION_SUMMARY" + "PACKAGE_DESCRIPTION" + ) + +# There's really only one homepage for a project, so +# re-use the Debian setting if it's there. +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_WWW" + "CPACK_DEBIAN_PACKAGE_HOMEPAGE" + "_cpack_freebsd_fallback_www" + ) + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_VERSION" + "CMAKE_PROJECT_VERSION" + "${CMAKE_PROJECT_NAME}_VERSION" + "PROJECT_VERSION" + "CPACK_PACKAGE_VERSION" + "CPACK_PACKAGE_VERSION" + ) + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_MAINTAINER" + "CPACK_PACKAGE_CONTACT" + ) + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_LICENSE" + "CPACK_RPM_PACKAGE_LICENSE" + ) + +_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_ORIGIN" + "_cpack_freebsd_fallback_origin" + ) + +if(NOT CPACK_FREEBSD_PACKAGE_CATEGORIES) + string(REGEX REPLACE "/.*" "" CPACK_FREEBSD_PACKAGE_CATEGORIES ${CPACK_FREEBSD_PACKAGE_ORIGIN}) +endif() + +check_required_var("CPACK_FREEBSD_PACKAGE_NAME") +check_required_var("CPACK_FREEBSD_PACKAGE_ORIGIN") +check_required_var("CPACK_FREEBSD_PACKAGE_VERSION") +check_required_var("CPACK_FREEBSD_PACKAGE_MAINTAINER") +check_required_var("CPACK_FREEBSD_PACKAGE_COMMENT") +check_required_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION") +check_required_var("CPACK_FREEBSD_PACKAGE_WWW") +check_required_var("CPACK_FREEBSD_PACKAGE_LICENSE") |