Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
Initial pass of cross-platform Debian and RPM packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgdev committed Nov 5, 2014
1 parent 0904a4c commit 7170822
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ OPTION (SERVED_BUILD_SHARED "Build shared object" ON)
OPTION (SERVED_BUILD_STATIC "Build static library" OFF)
OPTION (SERVED_BUILD_TESTS "Build unit test suite" ON)
OPTION (SERVED_BUILD_EXAMPLES "Build examples" ON)
OPTION (SERVED_BUILD_RPM "Build RPM package" OFF)
OPTION (SERVED_BUILD_DEB "Build DEB package" OFF)

#
# Debugging Options
Expand Down Expand Up @@ -95,3 +97,27 @@ IF (SERVED_BUILD_TESTS)
ENABLE_TESTING (true)
ENDIF (SERVED_BUILD_TESTS)
ADD_SUBDIRECTORY (src)

#
# CPack Generic
#
SET(CPACK_PACKAGE_NAME "libserved")
SET(CPACK_PACKAGE_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
SET(CPACK_PACKAGE_VERSION_MAJOR "${APPLICATION_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${APPLICATION_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${APPLICATION_VERSION_PATCH}")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Served is a C++ library for building high performance RESTful web servers")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_PACKAGE_VENDOR "${APPLICATION_VENDOR_NAME}")
SET(CPACK_PACKAGE_URL "${APPLICATION_VENDOR_URL}")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_SOURCE_GENERATOR "TGZ")

IF (SERVED_BUILD_DEB)
INCLUDE(CPackConfigDEB)
ENDIF (SERVED_BUILD_DEB)
IF (SERVED_BUILD_RPM)
INCLUDE(CPackConfigRPM)
ENDIF (SERVED_BUILD_RPM)

INCLUDE(CPack)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ SERVED_BUILD_SHARED | Build shared library
SERVED_BUILD_STATIC | Build static library
SERVED_BUILD_TESTS | Build unit test suite
SERVED_BUILD_EXAMPLES | Build bundled examples
SERVED_BUILD_DEB | Build DEB package (note: you must also have dpkg installed)
SERVED_BUILD_RPM | Build RPM package (note: you must also have rpmbuild installed)

## System Compatibility

Expand Down
30 changes: 30 additions & 0 deletions cmake/CPackConfigDEB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (C) 2014 MediaSift Ltd.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

FIND_PROGRAM(DPKG_CMD dpkg)
IF(DPKG_CMD)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_RELEASE "${APPLICATION_VERSION_TYPE}")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost (>= 1.53)")
SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "libboost-dev (>= 1.53)")
SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
EXECUTE_PROCESS(COMMAND ${DPKG_CMD} --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
ENDIF(DPKG_CMD)
30 changes: 30 additions & 0 deletions cmake/CPackConfigRPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (C) 2014 MediaSift Ltd.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

FIND_PROGRAM(RPMBUILD_CMD rpmbuild)
IF(RPMBUILD_CMD)
SET(CPACK_GENERATOR "RPM")
SET(CPACK_RPM_PACKAGE_RELEASE "${APPLICATION_VERSION_TYPE}")
SET(CPACK_RPM_PACKAGE_LICENSE "MIT")
SET(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
SET(CPACK_RPM_PACKAGE_REQUIRES "libboost >= 1.53")
SET(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
ENDIF(RPMBUILD_CMD)

0 comments on commit 7170822

Please sign in to comment.