From 0783d6aa3e74b76e2931e4547717229fa778b6b6 Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 18 Aug 2021 16:31:32 +0200 Subject: [PATCH] CMake: Add CPack for .deb and .rpm package generation. (#987) Compile as normal, run `cpack -G DEB` or `cpack -G RPM` in build directory. Tested on: - Debian 11 (bullseye) - OpenSUSE Leap 15 - Ubuntu 18.04 (bionic) Bug: https://github.com/drogonframework/drogon/issues/983 --- CMakeLists.txt | 1 + cmake/Packages.cmake | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 cmake/Packages.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 821cf097..181dce21 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -748,3 +748,4 @@ if(DOXYGEN_FOUND) endif(BUILD_DOC) endif(DOXYGEN_FOUND) +include(cmake/Packages.cmake) diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake new file mode 100644 index 00000000..e85db383 --- /dev/null +++ b/cmake/Packages.cmake @@ -0,0 +1,37 @@ +include(GNUInstallDirs) + +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_CONTACT "https://github.com/drogonframework/drogon") + +set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") +set(CPACK_PACKAGE_VERSION "${DROGON_VERSION}") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A C++14/17 based HTTP web application framework running on Linux/macOS/Unix/Windows") + +# DEB +# Figure out dependencies automatically. +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + +# Should be set automatically, but it is not. +execute_process(COMMAND dpkg --print-architecture + OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE + OUTPUT_STRIP_TRAILING_WHITESPACE) + +# The default does not produce valid Debian package names. +set(CPACK_DEBIAN_FILE_NAME + "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") + +# RPM +set(CPACK_RPM_PACKAGE_LICENSE "MIT") + +# Figure out dependencies automatically. +set(CPACK_RPM_PACKAGE_AUTOREQ ON) + +# Should be set automatically, but it is not. +execute_process(COMMAND uname -m + OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE + OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.${CPACK_RPM_PACKAGE_ARCHITECTURE}") + +include(CPack)