|
| 1 | +# Copyright (c) 2017 Raphael.Dumusc@epfl.ch |
| 2 | +# |
| 3 | +# Helper function for packaging subprojects using CommonCPack. |
| 4 | +# |
| 5 | +# Add subproject dependencies to the current project's package: |
| 6 | +# add_deb_depends(<Subproject> |
| 7 | +# [PACKAGE_NAME <subproject_package_name>] |
| 8 | +# [MIN_VERSION <subproject_min_version>] [<subproject_deb_depends>]) |
| 9 | +# |
| 10 | +# Arguments: |
| 11 | +# * Subproject: name of the subproject |
| 12 | +# * PACKAGE_NAME: if subproject package name differs from lower_case(Subproject) |
| 13 | +# * MIN_VERSION: minimum version of the subproject's package |
| 14 | +# * ARGN: list of dependencies of the subproject |
| 15 | +# |
| 16 | +# Output (list append): |
| 17 | +# * NAME_PACKAGE_REPLACES: Subproject package name if it is being built |
| 18 | +# * NAME_PACKAGE_DEB_DEPENDS: the list of Subproject's dependencies if it is |
| 19 | +# being built; otherwise its package name. |
| 20 | + |
| 21 | +macro(add_deb_depends Subproject) |
| 22 | + set(_opts) |
| 23 | + set(_singleArgs PACKAGE_NAME MIN_VERSION) |
| 24 | + set(_multiArgs) |
| 25 | + cmake_parse_arguments(THIS "${_opts}" "${_singleArgs}" "${_multiArgs}" |
| 26 | + ${ARGN}) |
| 27 | + set(_packages ${THIS_UNPARSED_ARGUMENTS}) |
| 28 | + |
| 29 | + if(THIS_PACKAGE_NAME) |
| 30 | + set(_subproject_pkg ${THIS_PACKAGE_NAME}) |
| 31 | + else() |
| 32 | + string(TOLOWER ${Subproject} _subproject_pkg) |
| 33 | + endif() |
| 34 | + |
| 35 | + if(${Subproject}_IS_SUBPROJECT) |
| 36 | + list(APPEND ${UPPER_PROJECT_NAME}_PACKAGE_REPLACES ${_subproject_pkg}) |
| 37 | + list(APPEND ${UPPER_PROJECT_NAME}_PACKAGE_DEB_DEPENDS ${_packages}) |
| 38 | + else() |
| 39 | + if(THIS_MIN_VERSION) |
| 40 | + set(_subproject_pkg "${_subproject_pkg} (>= ${THIS_MIN_VERSION})") |
| 41 | + endif() |
| 42 | + list(APPEND ${UPPER_PROJECT_NAME}_PACKAGE_DEB_DEPENDS "${_subproject_pkg}") |
| 43 | + endif() |
| 44 | +endmacro() |
0 commit comments