#  Copyright (C) 2026 ChiPass Team <contact@chipass.org>
#  Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
#  Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 2 or (at your option)
#  version 3 of the License.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

if (FREEDESKTOP)
  add_subdirectory(freedesktop)
endif()

if (CHIPASS_DIST_TYPE STREQUAL AppBundle)
  install(FILES macosx/ChiPass.icns DESTINATION ${CHIPASS_INSTALL_DATADIR})
endif()

# Not used during the build, but can be used to update platform-specific raster icons
# from the source png's.
add_custom_target(rebuild-icons)

# All platforms
add_custom_command(TARGET rebuild-icons POST_BUILD
  COMMAND bash ./icons/minify.sh
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

# macOS
if(APPLE)
  add_custom_command(TARGET rebuild-icons POST_BUILD
    COMMAND png2icns
      macosx/ChiPass.icns icons/application/256x256/apps/chipass.png
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  )
endif()

# Windows
add_custom_command(TARGET rebuild-icons POST_BUILD
  COMMAND bash ./windows/create-ico.sh
    icons/application/scalable/apps/chipass.svg windows/ChiPass.ico
  COMMAND bash ./windows/create-ico.sh
    icons/application/scalable/mimetypes/application-x-chipass.svg windows/ChiPass-kdbx.ico
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
