SET(CPACK_STRIP_FILES TRUE)

INSTALL( FILES "${SVG_ICON_FILE}" DESTINATION share/icons/hicolor/scalable/apps RENAME ${PROJECT_NAME}.svg )

FIND_PROGRAM(RSVG_CONVERT NAMES rsvg-convert)
MARK_AS_ADVANCED(RSVG_CONVERT)

FOREACH( SIZE "16" "32" "48" "64" "128" "256" )
  ADD_CUSTOM_COMMAND( OUTPUT icon_${SIZE}x${SIZE}.png
                      COMMAND ${RSVG_CONVERT} -w ${SIZE} -h ${SIZE} ${SVG_ICON_FILE} -o icon_${SIZE}x${SIZE}.png
                      DEPENDS ${SVG_ICON_FILE}
                    )
  ADD_CUSTOM_TARGET(icon_${SIZE}x${SIZE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/icon_${SIZE}x${SIZE}.png)
  INSTALL( FILES "${CMAKE_CURRENT_BINARY_DIR}/icon_${SIZE}x${SIZE}.png"
           DESTINATION share/icons/hicolor/${SIZE}x${SIZE}/apps RENAME ${PROJECT_NAME}.png )
ENDFOREACH()

SET( DESKTOP_FILE_VERSION    "${PROJECT_VERSION}" )
SET( DESKTOP_FILE_NAME       "${PROJECT_NAME}" )
SET( DESKTOP_FILE_COMMENT    "" )
SET( DESKTOP_FILE_EXEC       "${MAIN_EXECUTABLE}" )
SET( DESKTOP_FILE_ICON       "${PROJECT_NAME}" )
SET( DESKTOP_FILE_TERMINAL   "false" )
SET( DESKTOP_FILE_TYPE       "Application" )
SET( DESKTOP_FILE_CATEGORIES "Utiltiy;Application;" )

SET( DESKTOP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop" )
CONFIGURE_FILE( "${CMAKE_SOURCE_DIR}/ubuntu/desktopfile.in" "${DESKTOP_FILE}" )
INSTALL( FILES "${DESKTOP_FILE}" DESTINATION share/applications )

#License file
INSTALL( FILES "${CMAKE_SOURCE_DIR}/LICENSE"
         RENAME "copyright"
         DESTINATION "share/doc/${CPACK_PACKAGE_FILE_NAME}/"
         PERMISSIONS
         OWNER_WRITE OWNER_READ
         GROUP_READ
         WORLD_READ )

#changelog
EXECUTE_PROCESS( COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/ubuntu/changelog
                 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
                 OUTPUT_FILE "${CMAKE_BINARY_DIR}/changelog.gz" )
INSTALL( FILES "${CMAKE_BINARY_DIR}/changelog.gz"
         DESTINATION "share/doc/${CPACK_PACKAGE_FILE_NAME}/")

SET( CPACK_GENERATOR                 "DEB")
SET( CPACK_DEBIAN_PACKAGE_MAINTAINER "Your Name Here" )
SET( CPACK_DEBIAN_PACKAGE_SHLIBDEPS  ON )
