From 064e38eae9229298960a9f1db6fed9ccb9aa8219 Mon Sep 17 00:00:00 2001 From: Georg Sauthoff Date: Wed, 24 Aug 2016 08:42:36 +0200 Subject: [PATCH] add CPack packaging definition See also: - https://cmake.org/cmake/help/v3.4/module/CPack.html - https://cmake.org/cmake/help/v3.4/module/CPackRPM.html - https://cmake.org/cmake/help/v3.4/module/CPackDeb.html --- CMakeLists.txt | 27 ++++++++++++++++++++++++++- README.md | 26 ++++++++++++++++++++++++++ README_pkg.txt | 15 +++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 README_pkg.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index ab088bd..3ff0469 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,13 +43,38 @@ target_link_libraries(${PROJECT_NAME} mksh vroot pthread ) +# default install prefix is /usr/local +# change it with e.g. -DCMAKE_INSTALL_PREFIX=/usr install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) install(FILES man/man1/make.1 DESTINATION share/man/man1) install(FILES bin/make.rules.file DESTINATION share/${PROJECT_NAME} RENAME make.rules) install(FILES bin/svr4.make.rules.file DESTINATION share/${PROJECT_NAME} RENAME svr4.make.rules) -install(FILES README.md DESTINATION share/doc/${PROJECT_NAME} +install(FILES COPYING + README.md + DESTINATION share/doc/${PROJECT_NAME} ) install(DIRECTORY example DESTINATION share/doc/${PROJECT_NAME} ) + +# select the package generator with e.g. -DCPACK_GENERATOR='RPM;DEB' +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "illumos dmake, Sun make compatible") +set(CPACK_PACKAGE_CONTACT "mail@georg.so") +set(CPACK_PACKAGE_VENDOR "misc") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README_pkg.txt") +set(CPACK_RPM_PACKAGE_LICENSE "CDDL") +# used by some generators like NSI, is only displayed in the installer +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") +# only used by some generators +set(CPACK_PACKAGE_INSTALL_DIRECTORY + "${PROJECT_NAME}-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_MAJOR "0") +set(CPACK_PACKAGE_VERSION_MINOR "6") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_RPM_PACKAGE_GROUP "Development/Tools") +set(CPACK_RPM_PACKAGE_URL "https://github.com/gsauthof/somake") +# CPackDeb default to CPACK_PACKAGE_DESCRIPTION_SUMMARY, although +# the long description makes more sense ... +file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_DEBIAN_PACKAGE_DESCRIPTION) +include(CPack) diff --git a/README.md b/README.md index 887673a..5cb53e7 100644 --- a/README.md +++ b/README.md @@ -342,6 +342,32 @@ the following order: 5. `/usr/share/lib/make/make.rules` 6. `/etc/default/make.rules` +## Packaging + +The CMake build file `CMakeLists.txt` also defines some variables +for CPack, the CMake companion tool for creating binary packages. + +For example, to create `.rpm` and `.deb` packages: + + $ cmake ../somake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \ + -DCPACK_GENERATOR='RPM;DEB' -GNinja + $ ninja-build package + $ ls somake-* + somake-0.6.0-Linux.deb somake-0.6.0-Linux.rpm + +As always, the `-GNinja` generator option can be dropped - +`ninja-build` has to be replaced with `make` then. + +The content of the archives can be verified like this: + + $ dpkg --contents somake-0.6.0-Linux.deb + $ dpkg --info somake-0.6.0-Linux.deb + +Or: + + $ rpm2cpio somake-0.6.0-Linux.rpm | cpio --list -v + $ rpm -qip somake-0.6.0-Linux.rpm + ## License diff --git a/README_pkg.txt b/README_pkg.txt new file mode 100644 index 0000000..2e4a6ed --- /dev/null +++ b/README_pkg.txt @@ -0,0 +1,15 @@ +`somake` is a portable version of illumos make. illumos make is +derived from Sun's dmake (distributed make) which in turn is +compatible with the bonus features of Sun make. Notable Sun make +features are: + +- command dependencies (target is considered outdated if used + variable has changed) +- hidden dependencies (automatic dependency generation for + included headers) +- target groups +- conditional macro assignment (different syntax than with GNU + make) +- include file generation (similar to GNU make) + +See also: https://github.com/gsauthof/somake