Merge pull request #282 from klaussnd/debian-package

Add possibility to create a Debian/Ubuntu package
This commit is contained in:
Frank Pagliughi 2020-12-07 15:54:24 -05:00 committed by GitHub
commit bafe6b4100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -43,6 +43,7 @@ else()
option(PAHO_BUILD_STATIC "Build static library" FALSE)
option(PAHO_BUILD_SHARED "Build shared library" TRUE)
option(PAHO_WITH_SSL "Build SSL-enabled library" TRUE)
option(PAHO_BUILD_DEB_PACKAGE "Build debian package" FALSE)
endif()
option(PAHO_BUILD_SAMPLES "Build sample programs" FALSE)
@ -106,7 +107,12 @@ endif()
if(WIN32)
set(CPACK_GENERATOR "ZIP")
elseif(UNIX)
set(CPACK_GENERATOR "TGZ")
if(PAHO_BUILD_DEB_PACKAGE)
set(CPACK_GENERATOR "DEB")
include(cmake/CPackDebConfig.cmake)
else()
set(CPACK_GENERATOR "TGZ")
endif()
endif()
include(CPack)

View File

@ -116,6 +116,7 @@ PAHO_BUILD_DOCUMENTATION | FALSE | Create and install the HTML based API documen
PAHO_BUILD_SAMPLES | FALSE | Build sample programs
PAHO_BUILD_TESTS | FALSE | Build the unit tests. (This currently requires both _CppUnit_ and _Catch2_)
PAHO_WITH_SSL | TRUE (Linux), FALSE (Win32) | Flag that defines whether to build ssl-enabled binaries too
PAHO_BUILD_DEB_PACKAGE | FALSE | Flag that configures cpack to build a Debian/Ubuntu package
In addition, the C++ build might commonly use `CMAKE_PREFIX_PATH` to help the build system find the location of the Paho C library.
@ -204,6 +205,16 @@ or the `CMAKE_CXX_COMPILER` flag can be used:
$ cmake -DCMAKE_CXX_COMPILER=clang++
```
#### Building a Debian/Ubuntu package
```
$ cmake -Bbuild -H. -DPAHO_WITH_SSL=ON -DPAHO_ENABLE_TESTING=OFF -DPAHO_BUILD_DEB_PACKAGE=ON
$ cmake --build build
$ (cd build && cpack)
```
will generate a `.deb` file.
#### Updating CMake on Ubuntu 14.04 or 16.04
The versions of CMake on Ubuntu 14.04 or 16.04 LTS are pretty old and have some problems with Paho C++ library. A newer version can be added by downloading the source and building it. If the older cmake can be removed from the system using the package manager, or it can be kept, using the Ububtu alternatives to chose between the versions.

View File

@ -0,0 +1,10 @@
if(CPACK_GENERATOR MATCHES "DEB")
set(CPACK_PACKAGE_NAME "libpaho-mqtt.cpp")
set(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
set(CPACK_PACKAGE_CONTACT "Eclipse")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Eclipse Paho MQTT C++ client")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER " <>")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_VERSION ${PACKAGE_VERSION})
set(CPACK_DEBIAN_PACKAGE_SECTION "net")
endif()