set(ICONS_DEST share/geary/icons)

set(ICON_FILES
    application-menu.svg
    mail-inbox.png
    mail-outbox.svg
    mail-sent.png
    non-starred-grey.png
    starred.png
)

set(ICON_FILES_16
    16x16/format-text-none.svg
    16x16/mail-archive.svg
    16x16/tag.svg
    16x16/tag-new.svg
    16x16/tags.svg
)

set(ICON_FILES_24
    24x24/format-text-none.svg
    24x24/edit-mark.svg
    24x24/mail-archive.svg
    24x24/mail-move.svg
    24x24/tag.svg
    24x24/tag-new.svg
)

install(FILES ${ICON_FILES} DESTINATION ${ICONS_DEST})

install(FILES ${ICON_FILES_16} DESTINATION ${ICONS_DEST}/16x16)
install(FILES ${ICON_FILES_24} DESTINATION ${ICONS_DEST}/24x24)

# Application icon goes in theme directory
install(FILES "16x16/geary.svg" DESTINATION share/icons/hicolor/16x16/apps)
install(FILES "32x32/geary.svg" DESTINATION share/icons/hicolor/32x32/apps)
install(FILES "48x48/geary.svg" DESTINATION share/icons/hicolor/48x48/apps)
install(FILES "64x64/geary.svg" DESTINATION share/icons/hicolor/64x64/apps)
install(FILES "128x128/geary.svg" DESTINATION share/icons/hicolor/128x128/apps)

# Optional: update icon cache at install time.
if (ICON_UPDATE)
    install(
        CODE
            "execute_process (COMMAND gtk-update-icon-cache -t -f ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor)"
        CODE
            "message (STATUS \"Updated icon cache in ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor\")"
    )
    
    add_custom_target(
        uninstall-icon-cache
        COMMAND
            gtk-update-icon-cache -t -f ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
        COMMENT
            "Updated icon cache after uninstall in ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor"
    )
    
    add_dependencies(post-uninstall uninstall-icon-cache)
endif ()

