Skip to content

Commit

Permalink
build debian package
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Maas committed Dec 3, 2024
1 parent 9260321 commit 83848af
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
50 changes: 50 additions & 0 deletions cmake/modules/SetupCPack.cmake
Original file line number Diff line number Diff line change
@@ -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 "[email protected]")
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)

0 comments on commit 83848af

Please sign in to comment.