diff --git a/CMakeLists.txt b/CMakeLists.txt index d8c4148..7b445c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,3 +47,5 @@ endif() add_subdirectory(translations) add_subdirectory(man) + +include(cmake/packages.cmake) diff --git a/README.adoc b/README.adoc index d282741..7359bd3 100644 --- a/README.adoc +++ b/README.adoc @@ -123,7 +123,13 @@ cmake .. cmake --build . -- --jobs=$(nproc --ignore=1) -------------------------------------------------------------------------------- -To install, run `sudo make install`. To run the tests, run `cd tests && ctest`. +To install, run `sudo make install`. To run the tests, run `cd tests && +ctest`. + +[TIP] +If you are using Debian or Ubuntu, or a distribution that is derived from these, +you can run `cpack -G DEB` in the build directory to generate a .deb-file. You +can then install it with `apt install ./epubgrep-*.deb`. .CMake options: * `-DCMAKE_BUILD_TYPE=Debug` for a debug build. diff --git a/cmake/packages.cmake b/cmake/packages.cmake new file mode 100644 index 0000000..a47b913 --- /dev/null +++ b/cmake/packages.cmake @@ -0,0 +1,30 @@ +include(GNUInstallDirs) + +set(CPACK_PACKAGE_CHECKSUM "SHA512") +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_CONTACT "tastytea ") + +# Should be set automatically, but they are not. +set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") + +# 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) + +execute_process(COMMAND lsb_release --codename --short + OUTPUT_VARIABLE DEBIAN_CODENAME + OUTPUT_STRIP_TRAILING_WHITESPACE) +if ("${DEBIAN_CODENAME}" STREQUAL "n/a") + set(DEBIAN_CODENAME "unknown") +endif() + +# 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}_${DEBIAN_CODENAME}.deb") + +include(CPack)