SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The CellML SDK provides libraries for working with CellML models")
SET(CPACK_PACKAGE_VENDOR "Auckland Bioengineering Institute, The University of Auckland")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CMake_VERSION_MAJOR 1)
SET(CMake_VERSION_MINOR 13)
SET(GLOBAL_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "13")
SET(CPACK_PACKAGE_VERSION_PATCH "1")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "cellml-sdk-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")

SET(MSVC_DESCRIPTIVE "")
IF(WIN32)
  SET(CPACK_GENERATOR "ZIP")
  IF(MSVC)
    IF (${MSVC_VERSION} EQUAL "1200")
      SET(MSVC_DESCRIPTIVE "MSVC6")
    ELSEIF(${MSVC_VERSION} EQUAL "1300")
      SET(MSVC_DESCRIPTIVE "MSVC7")
    ELSEIF(${MSVC_VERSION} EQUAL "1310")
      SET(MSVC_DESCRIPTIVE "MSVC7-1")
    ELSEIF(${MSVC_VERSION} EQUAL "1400")
      SET(MSVC_DESCRIPTIVE "MSVC8")
    ELSEIF(${MSVC_VERSION} EQUAL "1500")
      SET(MSVC_DESCRIPTIVE "MSVC9")
    ELSEIF(${MSVC_VERSION} EQUAL "1600")
      SET(MSVC_DESCRIPTIVE "MSVC10")
    ELSEIF(${MSVC_VERSION} EQUAL "1700")
      SET(MSVC_DESCRIPTIVE "MSVC11")
    ELSE()
      SET(MSVC_DESCRIPTIVE "MSVCUNKNOWN")
    ENDIF()
    IF(CMAKE_BUILD_TYPE MATCHES ".*Debug.*")
      SET(CPACK_PACKAGE_FILE_NAME "cellml-sdk-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-Win32-${MSVC_DESCRIPTIVE}-Debug")
    ELSE(CMAKE_BUILD_TYPE MATCHES ".*Debug.*")
      SET(CPACK_PACKAGE_FILE_NAME "cellml-sdk-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-Win32-${MSVC_DESCRIPTIVE}")
    ENDIF(CMAKE_BUILD_TYPE MATCHES ".*Debug.*")
  ELSE(MSVC)
    SET(CPACK_PACKAGE_FILE_NAME "cellml-sdk-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-Win32-MingW")
  ENDIF(MSVC)
  INSTALL(FILES build/api-icon.ico DESTINATION icons)
  SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/build/api-icon.ico")
  SET(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/build/api-icon-uninst.ico")
  SET(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
  SET(CPACK_NSIS_DISPLAY_NAME "CellML SDK")
  SET(CPACK_NSIS_DISPLAY_NAME "CellML SDK")
  SET(CPACK_NSIS_HELP_LINK "http://cellml.org/tools/api")
  SET(CPACK_NSIS_CONTACT "cellml-tools-developers@lists.cellml.org")
ELSE()
  IF (APPLE)
    SET(CPACK_PACKAGE_FILE_NAME "cellml-sdk-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-Mac")
    SET(CPACK_BUNDLE_NAME "CellML SDK ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
    SET(CPACK_BUNDLE_ICON "build/api-icon.ico")
    SET(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/build/sdk-bundle.plist")
    SET(CPACK_GENERATOR "Bundle")
  ELSE()
    SET(CPACK_PACKAGE_FILE_NAME "cellml-sdk-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-Linux-${CMAKE_SYSTEM_PROCESSOR}")
    SET(CPACK_GENERATOR "TBZ2")
  ENDIF()
ENDIF()
INCLUDE(CPack)

ADD_CUSTOM_TARGET(release chmod "+x" "build/make-release" COMMAND sh build/make-release ${CMake_VERSION_MAJOR} ${CMake_VERSION_MINOR} ${CMAKE_BINARY_DIR} ${MSVC_DESCRIPTIVE})
