set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "${PROJECT_VENDOR_NAME}")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dist")
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_PACKAGE_DESCRIPTION "${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_HOMEPAGE_URL "${PROJECT_VENDOR_URL}")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-v${PROJECT_VERSION}-${PROJECT_OS_NAME}")

if(ANDROID)
    # android
    set(CPACK_GENERATOR "TGZ")
elseif(UNIX AND NOT APPLE AND NOT ANDROID)
    # linux
    set(CPACK_GENERATOR "DEB")
    set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/${PROJECT_NAME}")
    #set(CPACK_DEBIAN_FILE_NAME "${PACKAGE_TARNAME}.deb")
    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PROJECT_VENDOR_NAME}") # required
    set(CPACK_DEBIAN_PACKAGE_SECTION "web")
    set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
elseif(APPLE)
    # macos
    set(CPACK_GENERATOR "TGZ")
elseif(WIN32)
    # windows
    set(CPACK_GENERATOR "NSIS")
    set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_DISPLAY_NAME}")
    set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
    set(CPACK_NSIS_MODIFY_PATH ON)
    set(CPACK_NSIS_DISPLAY_NAME "${PROJECT_DISPLAY_NAME}")
    #set(CPACK_NSIS_PACKAGE_NAME "${PACKAGE_STRING}")
    set(CPACK_NSIS_URL_INFO_ABOUT "${PROJECT_VENDOR_URL}")
    if(CMAKE_SIZEOF_VOID_P EQUAL "8") # 64-bit package
        set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
    else() # 32-bit package
        set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
    endif()
endif()

include(CPack)
