#### Packaging setup for OGS-5 ####

#include(scripts/cmake/InstallRequiredSystemLibraries.cmake)

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OGS-5")
set(CPACK_PACKAGE_VENDOR "OpenGeoSys Development Team")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OGS-${OGS_VERSION_MAJOR}.${OGS_VERSION_MINOR}.${OGS_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_VERSION_MAJOR "${OGS_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${OGS_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${OGS_VERSION_PATCH}")
set(FILENAME "ogs")
set(CPACK_PACKAGE_FILE_NAME "${FILENAME}-${OGS_VERSION_MAJOR}.${OGS_VERSION_MINOR}.${OGS_VERSION_PATCH}-${CMAKE_SYSTEM}-x${BITS}")

if (OGS_PACKAGING_ZIP)
  set (CPACK_GENERATOR ZIP)
  message (STATUS "Packaging set to ZIP")
else ()
  if(WIN32)
    set(CPACK_GENERATOR NSIS)
    # There is a bug in NSI that does not handle full unix paths properly. Make
    # sure there is at least one set of four (4) backlasshes.
    set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/scripts/cmake\\\\OGS_Logo_Installer.bmp")
    #set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
    set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
    set(CPACK_NSIS_HELP_LINK "https:\\\\\\\\geosys.ufz.de")
    set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\geosys.ufz.de")
    set(CPACK_NSIS_CONTACT "lars.bilke@ufz.de")
    set(CPACK_NSIS_MODIFY_PATH ON)
    #set(CPACK_NSIS_MENU_LINKS "https://geosys.ufz.de/trac" "OGS Wiki")
    message (STATUS "Packaging set to NSIS")
  else()
    if(UNIX)
      set(CPACK_GENERATOR TGZ)
      message (STATUS "Packaging set to TGZ")
    else()
      if(APPLE)
		set(CPACK_GENERATOR TGZ)
	  	message (STATUS "Packaging set to TGZ")
      endif()
    endif()
    #set(CPACK_STRIP_FILES "bin/ogs")
    #set(CPACK_SOURCE_STRIP_FILES "")
  endif()
endif ()

set(CPACK_COMPONENT_OGS_DISPLAY_NAME "Executable")
set(CPACK_COMPONENT_OGS_DESCRIPTION "The command line executable (former rf4)")
set(CPACK_COMPONENT_MSVC_REDIST_DISPLAY_NAME "C++ Redistributable")
set(CPACK_COMPONENT_MSVC_REDIST_DESCRIPTION "Microsoft Visual C++ Redistributable")

set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
set(CPACK_PACKAGE_EXECUTABLES "ogs" "OGS Command Line")
set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ogs Unspecified)

include (CPack)
