# generators
MESSAGE("-- BUILD_DEB_PACKAGE ${BUILD_DEB_PACKAGE}")
MESSAGE("-- BUILD_RPM_PACKAGE ${BUILD_RPM_PACKAGE}")
MESSAGE("-- BUILD_PKGBUILD_PACKAGE ${BUILD_PKGBUILD_PACKAGE}")
SET(CPACK_GENERATOR "TGZ")
IF (BUILD_DEB_PACKAGE)
    set(CPACK_GENERATOR "${CPACK_GENERATOR}" "DEB")
ENDIF ()
IF (BUILD_RPM_PACKAGE)
    SET(CPACK_GENERATOR "${CPACK_GENERATOR}" "RPM")
ENDIF ()
IF (BUILD_PKGBUILD_PACKAGE)
    SET(CPACK_GENERATOR "${CPACK_GENERATOR}" "External")
ENDIF ()

SET(PKG_PKGBUILD_ARCH "any")
# build properties
SET(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")

# general metadata
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
INCLUDE(InstallRequiredSystemLibraries)
SET(CPACK_PACKAGE_CONTACT "${PROJECT_AUTHOR}")
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
SET(CPACK_PACKAGE_RELEASE "1")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")

SET(PACKAGE_DESCRIPTION "In I3 window manager, monitor the switch event of workspace and prompt on the desktop.")
# doesn't match to official arch :/
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")

# deb specific
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${PACKAGE_DESCRIPTION})
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "")
SET(CPACK_DEBIAN_PACKAGE_ENHANCES "")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "")
SET(CPACK_DEBIAN_PACKAGE_SECTION "")

# rpm specific
SET(CPACK_RPM_PACKAGE_DESCRIPTION ${PACKAGE_DESCRIPTION})
SET(CPACK_RPM_PACKAGE_GROUP "User Interface/Desktops")
SET(CPACK_RPM_PACKAGE_REQUIRES "")
SET(CPACK_RPM_PACKAGE_SUGGESTS "")
SET(CPACK_RPM_PACKAGE_URL "")


# archlinux specific
SET(PKG_CONFIG_TEMPLATE "${CMAKE_SOURCE_DIR}/cmake/PKGBUILD.in")
SET(PKG_CONFIG_FILE "PKGBUILD")
CONFIGURE_FILE("${PKG_CONFIG_TEMPLATE}" "${PKG_CONFIG_FILE}" @ONLY)
IF (BUILD_PKGBUILD_PACKAGE)
    SET(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/cpack_pkgbuild.cmake")
ENDIF ()

INCLUDE(CPack)
