cmake_policy(SET CMP0057 NEW)

if(CPACK_GENERATOR MATCHES "RPM")
    set(CPACK_RPM_BUILDREQUIRES "cmake >= ${CMAKE_MINIMUM_REQUIRED_VERSION}, systemd, gawk, gcc-c++ >= 4.9, python3, zlib-devel")
    if(CPACK_OS_RELEASE_NAME IN_LIST CPACK_RPM_DISTRIBUTIONS AND CPACK_OS_RELEASE_VERSION VERSION_GREATER "7")
        list(APPEND CPACK_RPM_BUILDREQUIRES "systemd-rpm-macros")
    endif()
    set(CPACK_RPM_PACKAGE_SOURCES OFF)
    set(CPACK_RPM_PACKAGE_REQUIRES "iproute, sed, systemd, libatomic")
    set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_LIST_DIR}/RPM_CHANGELOG")
    set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
    set(CPACK_RPM_PACKAGE_DESCRIPTION "The OpenZiti Edge Tunnel is a zero-trust tunneling software client.")
    set(CPACK_RPM_PACKAGE_GROUP "OpenZiti Client")
    set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0")
    set(CPACK_RPM_PACKAGE_RELEASE_DIST "OFF")
    set(CPACK_RPM_PACKAGE_SUMMARY "OpenZiti Edge Tunneling Software Client")
    set(CPACK_RPM_PACKAGE_URL "https://openziti.github.io/")
    
    set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CPACK_RPM_POST_INSTALL}")
    set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CPACK_RPM_PRE_UNINSTALL}")
    set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CPACK_RPM_POST_UNINSTALL}")
    set(CPACK_RPM_PACKAGE_REQUIRES_POST "systemd")
    set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "systemd")
    set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "systemd")
    #[[
    set(CPACK_RPM_ziti-edge-tunnel_PACKAGE_NAME "${CPACK_RPM_PACKAGE_NAME}")
    set(CPACK_RPM_ziti-edge-tunnel_FILE_NAME "RPM-DEFAULT")
    ]]
    endif(CPACK_GENERATOR MATCHES "RPM")

if(CPACK_GENERATOR MATCHES "DEB")
    set(CPACK_DEBIAN_PACKAGE_DEPENDS "iproute2, sed, systemd, libatomic1")
    set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEB_CONFFILES};${CPACK_DEB_POST_INSTALL};${CPACK_DEB_PRE_UNINSTALL};${CPACK_DEB_POST_UNINSTALL}")
endif(CPACK_GENERATOR MATCHES "DEB")
