# CPack configuration
if (NOT CMAKE_ARCH)
    message(FATAL_ERROR "CMAKE_ARCH is not set")
endif ()

if (NOT CPACK_PACKAGE_NAME)
	message(FATAL_ERROR "Root CMakeLists.txt must set CPACK_PACKAGE_NAME")
endif ()

if (NOT CPACK_PACKAGE_MAINTAINER)
	message(FATAL_ERROR "Root CMakeLists.txt must set CPACK_PACKAGE_MAINTAINER")
endif ()

if (NOT CPACK_PACKAGE_DESCRIPTION)
	message(FATAL_ERROR "Root CMakeLists.txt must set CPACK_PACKAGE_DESCRIPTION")
endif ()

if (NOT CPACK_PACKAGE_VENDOR)
	message(FATAL_ERROR "Root CMakeLists.txt must set PACKAGE_VENDOR")
endif ()

if (NOT CMAKE_INSTALL_PREFIX)
	message(FATAL_ERROR "Root CMakeLists.txt must set CMAKE_INSTALL_PREFIX")
endif ()

set(CPACK_PACKAGE_VENDOR ${CPACK_PACKAGE_VENDOR})
set(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION}.${COMMIT_VERSION})
set(CPACK_ARCHITECTUR ${CMAKE_ARCH})
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS)
set(CPACK_GENERATOR DEB)
set(CPACK_SOURCE_GENERATOR DEB)
set(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_ARCH})
set(CPACK_DEBIAN_PACKAGE_DEPENDS)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Artur Troian <developer@trysimply.com>")

set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Simply API for Wulian")
set(CPACK_DEBIAN_PACKAGE_SECTION devel)
set(CPACK_DEBIAN_COMPRESSION_TYPE gzip)
set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
set(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}.${HASH_VERSION}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")

set(PACKAGE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}.${HASH_VERSION}")

set(CPACK_SET_DESTDIR "on")
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})

set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${PACKAGE_CONTROL_EXTRA})
