diff --git a/CMakeLists.txt b/CMakeLists.txt index fceb9c156..b391776ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,7 @@ option(KAHYPAR_ENABLE_TESTING "Enables tests, which requires dowloading googlete option(KAHYPAR_STATIC_LINK_DEPENDENCIES "In static build, also link dependencies (other than TBB) statically." OFF) option(KAHYPAR_STATIC_LINK_TBB "In static build, also link TBB statically. Note that this is not officially supported!" OFF) option(KAHYPAR_INSTALL_CLI "Provide a target to install an executable binary `mtkahypar`." OFF) +option(KAHYPAR_BUILD_PACKAGE "Provide a target to build a debian package." OFF) # dependencies option(KAHYPAR_DOWNLOAD_BOOST "Download boost automatically and compile required libraries." OFF) @@ -515,6 +516,11 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) include(SetupInstallation) endif() + if(KAHYPAR_BUILD_PACKAGE) + # packaging via CPack + include(SetupCPack) + endif() + if(KAHYPAR_SETUP_PYTHON AND DEFINED KAHYPAR_TBB_DIR) # preparation for python wheel configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml.in ${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml @ONLY) diff --git a/cmake/modules/SetupCPack.cmake b/cmake/modules/SetupCPack.cmake new file mode 100644 index 000000000..2e82778c2 --- /dev/null +++ b/cmake/modules/SetupCPack.cmake @@ -0,0 +1,50 @@ +# Setup for packaging via cpack +# Based on https://decovar.dev/blog/2021/09/23/cmake-cpack-package-deb-apt/ + +set(CPACK_VERBATIM_VARIABLES ON) + +set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "") +set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/packages" CACHE STRING "") + + +# metadata +set(CPACK_PACKAGE_NAME "mtkahypar" CACHE STRING "") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION} CACHE STRING "") +# set(CPACK_PACKAGE_VENDOR "") + +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") + +set(CPACK_PACKAGE_CONTACT "nikolai.maas@kit.edu") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nikolai Maas <${CPACK_PACKAGE_CONTACT}>") + + +# installation options +set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_STRIP_FILES ON) +set( + CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE +) + +# determine debian dependencies automatically +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) + + +include(CPack) +message(STATUS "Package components: ${CPACK_COMPONENTS_ALL}") + +# custom command for actually building the package +find_program(CPACK_COMMAND cpack REQUIRED) +add_custom_target(package-mtkahypar-deb + ${CPACK_COMMAND} -G=DEB + DEPENDS MtKaHyPar-CLI mtkahypar)