CMakeLists.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
  2. # Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 2 or (at your option)
  7. # version 3 of the License.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. add_subdirectory(translations)
  17. file(GLOB wordlists_files "wordlists/*.wordlist")
  18. install(FILES ${wordlists_files} DESTINATION ${DATA_INSTALL_DIR}/wordlists)
  19. # Copy wordlists to build dir for use in tests
  20. file(COPY "wordlists" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
  21. if(UNIX AND NOT APPLE AND NOT HAIKU)
  22. # Flatpak requires all host accessible files to use filenames based upon the app id
  23. if(KEEPASSXC_DIST_FLATPAK)
  24. set(APP_ICON_NAME "${APP_ID}")
  25. set(MIME_ICON "${APP_ID}-application-x-keepassxc")
  26. configure_file(linux/keepassxc.xml.in ${CMAKE_CURRENT_BINARY_DIR}/linux/${APP_ID}.xml @ONLY)
  27. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/linux/${APP_ID}.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages)
  28. file(GLOB_RECURSE ICON_FILES LIST_DIRECTORIES false
  29. "icons/application/*/keepassxc*.png"
  30. "icons/application/*/*keepassxc*.svg")
  31. foreach(icon_match ${ICON_FILES})
  32. get_filename_component(icon_name ${icon_match} NAME)
  33. get_filename_component(icon_dir ${icon_match} DIRECTORY)
  34. # Prefix all icons with application id: "org.keepassxc.KeePassXC"
  35. string(REGEX REPLACE "^keepassxc(.*)?(\\.png|\\.svg)$" "${APP_ID}\\1\\2" icon_name ${icon_name})
  36. string(REGEX REPLACE "^(application-x-keepassxc\\.svg)$" "${APP_ID}-\\1" icon_name ${icon_name})
  37. # Find icon sub dir ex. "scalable/mimetypes/"
  38. file(RELATIVE_PATH icon_subdir ${CMAKE_CURRENT_SOURCE_DIR}/icons/application ${icon_dir})
  39. install(FILES ${icon_match} DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${icon_subdir}
  40. RENAME ${icon_name})
  41. endforeach()
  42. else()
  43. set(APP_ICON_NAME "keepassxc")
  44. set(MIME_ICON "application-x-keepassxc")
  45. configure_file(linux/keepassxc.xml.in ${CMAKE_CURRENT_BINARY_DIR}/linux/keepassxc.xml @ONLY)
  46. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/linux/keepassxc.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages)
  47. install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
  48. FILES_MATCHING PATTERN "keepassx*.png" PATTERN "keepassx*.svg"
  49. PATTERN "status" EXCLUDE PATTERN "actions" EXCLUDE PATTERN "categories" EXCLUDE)
  50. install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
  51. FILES_MATCHING PATTERN "application-x-keepassxc.svg" PATTERN "status"
  52. EXCLUDE PATTERN "actions" EXCLUDE PATTERN "categories" EXCLUDE)
  53. endif(KEEPASSXC_DIST_FLATPAK)
  54. configure_file(linux/${APP_ID}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/linux/${APP_ID}.desktop @ONLY)
  55. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/linux/${APP_ID}.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  56. install(FILES linux/${APP_ID}.appdata.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
  57. endif(UNIX AND NOT APPLE AND NOT HAIKU)
  58. if(APPLE)
  59. install(FILES macosx/keepassxc.icns DESTINATION ${DATA_INSTALL_DIR})
  60. endif()
  61. if(WIN32)
  62. install(FILES windows/qt.conf DESTINATION ${BIN_INSTALL_DIR})
  63. endif()
  64. install(FILES icons/application/256x256/apps/keepassxc.png DESTINATION ${DATA_INSTALL_DIR}/icons/application/256x256/apps)
  65. add_custom_target(icons)
  66. add_custom_command(TARGET icons
  67. COMMAND bash ./icons/minify.sh
  68. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  69. if(APPLE)
  70. add_custom_command(TARGET icons
  71. COMMAND png2icns macosx/keepassxc.icns icons/application/256x256/apps/keepassxc.png
  72. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  73. endif()
  74. # ICO for Windows
  75. add_custom_command(TARGET icons
  76. COMMAND bash ./windows/create-ico.sh icons/application/scalable/apps/keepassxc.svg windows/keepassxc.ico
  77. COMMAND bash ./windows/create-ico.sh icons/application/scalable/mimetypes/application-x-keepassxc.svg windows/keepassxc-kdbx.ico
  78. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})