# This file is configured at cmake time, and loaded at cpack time.
# To pass variables to cpack from cmake, they must be configured
# in this file.

set (CPACK_PACKAGE_VENDOR "@PROJECT_VENDOR@")
set (CPACK_PACKAGE_CONTACT "@PROJECT_CONTACT@")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "@PROJECT_SUMMARY_DESCRIPTION@")
set (CPACK_RESOURCE_FILE_LICENSE "@PROJECT_SOURCE_DIR@/COPYING")
if(CPACK_GENERATOR MATCHES "NSIS")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "@WSJTX_VERSION_PATCH@")
else()
set (CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
endif()
set (CPACK_PACKAGE_EXECUTABLES jtdx "@PROJECT_NAME@")
set (CPACK_CREATE_DESKTOP_LINKS jtdx)
set (CPACK_STRIP_FILES TRUE)

#
# components
#
#set (CPACK_COMPONENTS_ALL runtime)
#set (CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "@PROJECT_NAME@ Application")
#set (CPACK_COMPONENT_RUNTIME_DESCRIPTION "@WSJTX_DESCRIPTION_SUMMARY@")

if (CPACK_GENERATOR MATCHES "NSIS")
  set (CPACK_STRIP_FILES FALSE)	# breaks Qt packaging on Windows

  if("@CMAKE_SIZEOF_VOID_P@" EQUAL 8)
  set (CPACK_NSIS_INSTALL_ROOT "C:\\JTDX64")
  else()
  set (CPACK_NSIS_INSTALL_ROOT "C:\\JTDX32")
  endif()

  # set the install/unistall icon used for the installer itself
  # There is a bug in NSI that does not handle full unix paths properly.
  set (CPACK_NSIS_MUI_ICON "@PROJECT_SOURCE_DIR@/icons/windows-icons\\jtdx.ico")
  set (CPACK_NSIS_MUI_UNIICON "@PROJECT_SOURCE_DIR@/icons/windows-icons\\jtdx.ico")
  # set the package header icon for MUI
  set (CPACK_PACKAGE_ICON "@PROJECT_SOURCE_DIR@/icons/windows-icons\\installer_logo.bmp")
  # tell cpack to create links to the doc files
  set (CPACK_NSIS_MENU_LINKS
    "@PROJECT_MANUAL_DIRECTORY_URL@/@PROJECT_MANUAL@" "@PROJECT_NAME@ Documentation"
    "@PROJECT_HOMEPAGE@" "@PROJECT_NAME@ Web Site"
    )
  # Use the icon from jtdx for add-remove programs
  set (CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\jtdx.exe")

  set (CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
  set (CPACK_NSIS_HELP_LINK "@PROJECT_MANUAL_DIRECTORY_URL@/@PROJECT_MANUAL@")
  set (CPACK_NSIS_URL_INFO_ABOUT "@PROJECT_HOMEPAGE@")
  set (CPACK_NSIS_CONTACT "${CPACK_PACKAGE_CONTACT}")
  set (CPACK_NSIS_MUI_FINISHPAGE_RUN "jtdx.exe")
  set (CPACK_NSIS_MODIFY_PATH ON)

  # Setup the installer and uninstall VersionInfo resource
  set (CPACK_NSIS_EXTRA_DEFINES
    "VIProductVersion @WSJTX_VERSION_MAJOR@.@WSJTX_VERSION_MINOR@.@WSJTX_VERSION_SUB@.@WSJTX_VERSION_IS_RELEASE@
VIFileVersion @WSJTX_VERSION_MAJOR@.@WSJTX_VERSION_MINOR@.@WSJTX_VERSION_SUB@.@WSJTX_VERSION_IS_RELEASE@
VIAddVersionKey /LANG=0 \"ProductName\" \"@PROJECT_NAME@\"
VIAddVersionKey /LANG=0 \"ProductVersion\" \"v@WSJTX_VERSION_MAJOR@.@WSJTX_VERSION_MINOR@.@WSJTX_VERSION_PATCH@\"
VIAddVersionKey /LANG=0 \"Comments\" \"@PROJECT_DESCRIPTION@\"
VIAddVersionKey /LANG=0 \"CompanyName\" \"@PROJECT_VENDOR@\"
VIAddVersionKey /LANG=0 \"LegalCopyright\" \"@PROJECT_COPYRIGHT@\"
VIAddVersionKey /LANG=0 \"FileDescription\" \"@PROJECT_NAME@ Installer\"
VIAddVersionKey /LANG=0 \"FileVersion\" \"v@WSJTX_VERSION_MAJOR@.@WSJTX_VERSION_MINOR@.@WSJTX_VERSION_PATCH@\""
    )
endif ()

if ("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
  set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-pkg")
  set (CPACK_PACKAGE_DEFAULT_LOCATION "/Applications")
  set (CPACK_PACKAGING_INSTALL_PREFIX "/")
endif ()

if ("${CPACK_GENERATOR}" STREQUAL "DragNDrop")
  set (CPACK_DMG_VOLUME_NAME "@PROJECT_NAME@")
  set (CPACK_DMG_BACKGROUND_IMAGE "@PROJECT_SOURCE_DIR@/icons/Darwin/DragNDrop Background.png")
  set (CPACK_DMG_DS_STORE "@PROJECT_SOURCE_DIR@/Darwin/jtdx_DMG.DS_Store")
  set (CPACK_BUNDLE_NAME "@WSJTX_BUNDLE_NAME@")
  set (CPACK_PACKAGE_ICON "@PROJECT_BINARY_DIR@/jtdx.icns")
  set (CPACK_BUNDLE_ICON "@PROJECT_BINARY_DIR@/jtdx.icns")
  set (CPACK_BUNDLE_STARTUP_COMMAND "@PROJECT_SOURCE_DIR@/Mac-jtdx-startup.sh")
endif ()

if ("${CPACK_GENERATOR}" STREQUAL "WIX")
  # Reset CPACK_PACKAGE_VERSION to deal with WiX restriction.
  # But the file names still use the full CMake_VERSION value:
  set (CPACK_PACKAGE_FILE_NAME
    "${CPACK_PACKAGE_NAME}-@wsjtx_VERSION@-${CPACK_SYSTEM_NAME}")
  set (CPACK_SOURCE_PACKAGE_FILE_NAME
    "${CPACK_PACKAGE_NAME}-@wsjtx_VERSION@-Source")

  if (NOT CPACK_WIX_SIZEOF_VOID_P)
    set (CPACK_WIX_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@")
  endif ()
endif ()

if ("${CPACK_GENERATOR}" STREQUAL "DEB")
  set (CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE})
  set (CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} Debian)
  set (CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
endif ("${CPACK_GENERATOR}" STREQUAL "DEB")

if ("${CPACK_GENERATOR}" STREQUAL "RPM")
  set (CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CPACK_RPM_PACKAGE_ARCHITECTURE})
  set (CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
  set (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/local;/usr/local/bin;/usr/local/share;/usr/local/share/applications")
endif ("${CPACK_GENERATOR}" STREQUAL "RPM")

message (STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
