# -------------------------------------------------------------------------
# Build a CPack installer
# -------------------------------------------------------------------------

SET(CPACK_PACKAGE_NAME ${APP_NAME})
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${APP_NAME} - import, analyze and visualize metabolomics and genomics data.")
SET(CPACK_PACKAGE_VENDOR "Kitware, Inc.")

CONFIGURE_FILE(
  ${CMAKE_CURRENT_SOURCE_DIR}/NOTICE
  ${CMAKE_CURRENT_BINARY_DIR}/NOTICE.txt
  @ONLY)
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/NOTICE.txt")
CONFIGURE_FILE(
  ${CMAKE_CURRENT_SOURCE_DIR}/ABOUT
  ${CMAKE_CURRENT_BINARY_DIR}/ABOUT.txt
  @ONLY)
SET(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_BINARY_DIR}/ABOUT.txt")
CONFIGURE_FILE(
  ${CMAKE_CURRENT_SOURCE_DIR}/README
  ${CMAKE_CURRENT_BINARY_DIR}/README.txt
  @ONLY)
SET(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_BINARY_DIR}/README.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/NOTICE.txt")

SET(CPACK_PACKAGE_VERSION_MAJOR "${Visomics_MAJOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "${Visomics_MINOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_PATCH "${Visomics_BUILD_VERSION}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${APP_NAME} ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${APP_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_PACKAGE_EXECUTABLES "${APP_NAME};${APP_NAME}")
SET(CPACK_CREATE_DESKTOP_LINKS "visomics ${Visomics_VERSION}")

IF(Q_WS_WIN)
  INSTALL(FILES ${Visomics_SOURCE_DIR}/Base/Resources/Icons/visomics.ico
    DESTINATION ${Visomics_INSTALL_BIN_DIR} COMPONENT Runtime)
ENDIF()

CONFIGURE_FILE(
  ${PROJECT_SOURCE_DIR}/CMake/VisomicsCPackOptions.cmake.in
  ${PROJECT_BINARY_DIR}/VisomicsCPackOptions.cmake
  @ONLY)
SET(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/VisomicsCPackOptions.cmake")

if(APPLE)
  set(CPACK_PACKAGING_INSTALL_PREFIX "/Applications/${APP_NAME}")
else()
  set(CPACK_PACKAGING_INSTALL_PREFIX "/")
endif()

# -------------------------------------------------------------------------
# Install Visomics
# -------------------------------------------------------------------------
set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};Visomics;Runtime;/")


INCLUDE (InstallRequiredSystemLibraries)
INCLUDE(CPack)
