Skip to content

Commit

Permalink
Add macro in CommonCPackUtils to help package subprojects
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Dumusc committed Dec 15, 2017
1 parent 61e9179 commit ab06fad
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ include(CommonInstallProject)
include(CommonLibrary)
include(CommonCompiler)
include(CommonCoverage)
include(CommonCPackUtils)
include(CommonSmokeTest)
include(GitInfo)
include(GitTargets)
Expand Down
44 changes: 44 additions & 0 deletions CommonCPackUtils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2017 [email protected]
#
# Helper function for packaging subprojects using CommonCPack.
#
# Add subproject dependencies to the current project's package:
# add_deb_depends(<Subproject>
# [PACKAGE_NAME <subproject_package_name>]
# [MIN_VERSION <subproject_min_version>] [<subproject_deb_depends>])
#
# Arguments:
# * Subproject: name of the subproject
# * PACKAGE_NAME: if subproject package name differs from lower_case(Subproject)
# * MIN_VERSION: minimum version of the subproject's package
# * ARGN: list of dependencies of the subproject
#
# Output (list append):
# * NAME_PACKAGE_REPLACES: Subproject package name if it is being built
# * NAME_PACKAGE_DEB_DEPENDS: the list of Subproject's dependencies if it is
# being built; otherwise its package name.

macro(add_deb_depends Subproject)
set(_opts)
set(_singleArgs PACKAGE_NAME MIN_VERSION)
set(_multiArgs)
cmake_parse_arguments(THIS "${_opts}" "${_singleArgs}" "${_multiArgs}"
${ARGN})
set(_packages ${THIS_UNPARSED_ARGUMENTS})

if(THIS_PACKAGE_NAME)
set(_subproject_pkg ${THIS_PACKAGE_NAME})
else()
string(TOLOWER ${Subproject} _subproject_pkg)
endif()

if(${Subproject}_IS_SUBPROJECT)
list(APPEND ${UPPER_PROJECT_NAME}_PACKAGE_REPLACES ${_subproject_pkg})
list(APPEND ${UPPER_PROJECT_NAME}_PACKAGE_DEB_DEPENDS ${_packages})
else()
if(THIS_MIN_VERSION)
set(_subproject_pkg "${_subproject_pkg} (>= ${THIS_MIN_VERSION})")
endif()
list(APPEND ${UPPER_PROJECT_NAME}_PACKAGE_DEB_DEPENDS "${_subproject_pkg}")
endif()
endmacro()

0 comments on commit ab06fad

Please sign in to comment.