Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a cpack configuration for library packaging #426

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,49 @@ if(AMQP-CPP_LINUX_TCP)
find_package(OpenSSL REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENSSL_INCLUDE_DIR})
endif()

# software packaging
# ------------------------------------------------------------------------------------------------------

# if unix use deb and rpm generators, else default to .tar.gz
if (UNIX)
set(CPACK_GENERATOR DEB RPM)
endif (UNIX)

# general cpack settings
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ library for communicating with a RabbitMQ message broker")
set(CPACK_PACKAGE_VENDOR "Coppernica Marketing Software")
set(CPACK_PACKAGE_CONTACT "Copernica <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION
"AMQP-CPP is a C++ library for communicating with a RabbitMQ message broker. The
library can be used to parse incoming data from a RabbitMQ server, and to
generate frames that can be sent to a RabbitMQ server."
)
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/CopernicaMarketingSoftware/AMQP-CPP")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE
)
Comment on lines +159 to +167
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is wise. Why not leave it at the default?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually restricting the rights compared with the automatically generated folders by the install commands in this CMakeLists.txt.
As the generated folders were having too lax permissions lintian was complaining.
I believe it is the same issues that happened here: https://gitlab.kitware.com/cmake/cmake/-/issues/17333

But you are right, the more accurate approach would be to set the folder rights at the file install time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update:
After a little research it seems CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS and CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS are the only way to set permissions for directories implicitly created at install time.
Next Acions
I can change the way to set it to CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS though to be completely identical between install and package target.

set(CPACK_STRIP_FILES ON)

# deb generator related
set(CPACK_DEBIAN_PACKAGE_NAME "amqpcpp-dev")
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian/triggers")

# rpm generator related
set(CPACK_RPM_PACKAGE_NAME "amqpcpp-devel")
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")

# create package target
include(CPack)
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ On Windows you are required to define `NOMINMAX` when compiling code that includ

## Using cmake

The CMake file supports both building and installing. You can choose not to use
the install functionality, and instead manually use the build output at `build/bin/`. Keep
in mind that the TCP module is only supported for Linux. An example install method
The CMake file supports building, packaging, and installing. You can choose not to use
the install functionality, and instead manually use the build output at `build/bin/`.
You can also choose to generate packages for your system with the target `package` and install those.
Keep in mind that the TCP module is only supported for Linux. An example install method
would be:

```bash
Expand Down
1 change: 1 addition & 0 deletions debian/triggers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
activate-noawait ldconfig