Skip to content

Commit

Permalink
Merge a80e534 into c81eca3
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Feb 29, 2020
2 parents c81eca3 + a80e534 commit 061c5cc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Expand Up @@ -97,6 +97,24 @@ install(
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)

# packaging

if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CPACK_PACKAGE_CONTACT "prometheus-cpp@@noreply.github.com")
set(CPACK_PACKAGE_DESCRIPTION "C++ library for Prometheus exporters")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/jupp0r/prometheus-cpp")
set(CPACK_PACKAGE_RELOCATABLE OFF)
set(CPACK_PACKAGE_VENDOR "The prometheus-cpp authors")

set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

set(CPACK_RPM_PACKAGE_AUTOREQPROV ON)
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)

include(CPack)
endif()

# summary

include(FeatureSummary)
Expand Down
27 changes: 27 additions & 0 deletions README.md
Expand Up @@ -143,6 +143,33 @@ you load the following dependencies, if they do not exist yet, into your project

The list of dependencies is also available from file [repositories.bzl](bazel/repositories.bzl).

## Packaging

By configuring CPack you can generate an installer like a
Debian package (.deb) or RPM (.rpm) for the static or dynamic
libraries so they can be easily installed on
other systems.

Please refer to the [CPack](https://cmake.org/cmake/help/latest/module/CPack.html)
documentation for all available generators and their
configuration options.

To generate a Debian package you could follow these steps:

``` shell
# fetch third-party dependencies
git submodule update --init

# run cmake
cmake -B_build -DCPACK_GENERATOR=DEB -DBUILD_SHARED_LIBS=ON # or OFF for static libraries

# build and package
cmake --build _build --target package --parallel $(nproc)
```

This will place an appropriately named .deb in the
`_build` folder. To build a RPM package set the `CPACK_GENERATOR`
variable to `RPM`.

## Contributing

Expand Down

0 comments on commit 061c5cc

Please sign in to comment.