set(CPACK_GENERATOR "TGZ;RPM;DEB")

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
    set(CPACK_PACKAGE_NAME ${PROJECT_NAME}-dbg)
else()
    set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
endif()

set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY "Flutter Engine - ${CMAKE_BUILD_TYPE}")
set(CPACK_PACKAGE_VENDOR "Toyota Motor Corporation")
set(CPACK_PACKAGE_CONTACT "joel.winarske@woven-planet.global")

set(CPACK_VERBATIM_VARIABLES YES)

set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/_packages")

set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)

set(CPACK_DEB_COMPONENT_INSTALL YES)

set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Joel Winarske <joel.winarske@woven-planet.global>")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

set(CPACK_RPM_COMPONENT_INSTALL YES)
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
set(CPACK_RPM_PACKAGE_LICENSE "BSD-3-Clause License")
set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}")
set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY}")

set(CPACK_TGZ_FILE_NAME TGZ-DEFAULT)

if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
    set(CPACK_STRIP_FILES homescreen)
endif()

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
    set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON)
    set(CMAKE_RPM_DEBUGINFO_PACKAGE ON)
    set(CMAKE_TGZ_DEBUGINFO_PACKAGE ON)
endif()

include(CPack)
