create_package.cmake 3.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
# Command line arguments:
#   CONFIG = [Debug|Release]
#   COMPONENT = [SEQUENTIAL|PARALLEL]

set(PACKAGE_NAME "libamdis")

if ("${COMPONENT}" STREQUAL "PARALLEL")
  set(PACKAGE_NAME "${PACKAGE_NAME}-par")
  set(ADDITIONAL_FLAGS "-DENABLE_UMFPACK:BOOL=OFF -DENABLE_PARALLEL_DOMAIN:BOOL=ON")
else ()
  set(ADDITIONAL_FLAGS "-DENABLE_UMFPACK:BOOL=ON")
endif ()

if ("${CONFIG}" STREQUAL "Debug")
  set(PACKAGE_NAME "${PACKAGE_NAME}-dbg")
  set(PACKAGE_SECTION "debug")
else ()
  set(PACKAGE_SECTION "misc")
endif ()
# set(PACKAGE_NAME "${PACKAGE_NAME}-dev")

set(IN_DIR  ${CMAKE_SOURCE_DIR}/tools/packaging/debian)
set(OUT_DIR ${CMAKE_SOURCE_DIR}/debian_package)
file(MAKE_DIRECTORY ${OUT_DIR})


configure_file(${IN_DIR}/CPackOptions.cmake.in ${OUT_DIR}/CPackOptions.cmake @ONLY)
include(${OUT_DIR}/CPackOptions.cmake)

set(PACKAGE_FILENAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION})
set(PACKAGE_PREFIX ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
set(TGZ_FILENAME ${OUT_DIR}/${PACKAGE_FILENAME}.orig.tar.gz)

execute_process(COMMAND git archive --format=tar.gz --prefix ${PACKAGE_PREFIX}/ -o ${TGZ_FILENAME} master)
execute_process(COMMAND date +%F OUTPUT_VARIABLE CURRENT_DATE)
execute_process(COMMAND date +%Y OUTPUT_VARIABLE YEAR)

set(PACKAGE_VERSION       ${CPACK_PACKAGE_VERSION})
SET(PACKAGE_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR})
SET(PACKAGE_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR})
SET(PACKAGE_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH})
set(PACKAGE_SOURCE        "<https://gitlab.math.tu-dresden.de/iwr/amdis.git>")
set(PACKAGE_CONTACT       ${CPACK_PACKAGE_CONTACT})
execute_process(COMMAND date OUTPUT_VARIABLE PACKAGE_DATE)

file(READ ${CMAKE_SOURCE_DIR}/AUTHORS PACKAGE_AUTHORS)
set(PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
set(PACKAGE_DESCRIPTION         ${CPACK_PACKAGE_DESCRIPTION})

set(PACKAGE_LICENSE_FILE     ${CMAKE_SOURCE_DIR}/LICENSE)
set(PACKAGE_README_FILE      ${CMAKE_SOURCE_DIR}/README.md)
set(PACKAGE_DESCRIPTION_FILE ${PACKAGE_README_FILE})

# extract package generated by CPack
execute_process(COMMAND tar -xzf ${TGZ_FILENAME} -C ${OUT_DIR})

set(DEBIAN_DIR ${OUT_DIR}/${PACKAGE_PREFIX}/debian)

# generate necessary files for debian packages
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/CHANGELOG)
  configure_file(${IN_DIR}/debian.changelog.in ${CMAKE_SOURCE_DIR}/CHANGELOG @ONLY)
elseif (UPDATE_CHANGELOG)
  execute_process(COMMAND dch -i -M "New release version published at ${CURRENT_DATE}" -c ${CMAKE_SOURCE_DIR}/CHANGELOG)
endif ()
message(STATUS "Changelog must be uploaded to master")

file(MAKE_DIRECTORY ${DEBIAN_DIR})
file(MAKE_DIRECTORY ${DEBIAN_DIR}/soure)

configure_file(${CMAKE_SOURCE_DIR}/CHANGELOG ${DEBIAN_DIR}/changelog COPYONLY)
configure_file(${IN_DIR}/debian.copyright.in ${DEBIAN_DIR}/copyright @ONLY)
configure_file(${IN_DIR}/debian.control.in   ${DEBIAN_DIR}/control   @ONLY)
configure_file(${IN_DIR}/debian.rules.in     ${DEBIAN_DIR}/rules     @ONLY)
execute_process(COMMAND chmod +x ${DEBIAN_DIR}/rules)
file(WRITE ${DEBIAN_DIR}/compat "9\n")
file(WRITE ${DEBIAN_DIR}/soure/format "3.0 (quilt)\n")


# generate the debian package
80
execute_process(COMMAND debuild -d -us -uc
81
                WORKING_DIRECTORY ${OUT_DIR}/${PACKAGE_PREFIX})