CMakeLists.txt 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. configure_file(linux/${APP_ID}.policy.in ${CMAKE_CURRENT_BINARY_DIR}/linux/${APP_ID}.policy @ONLY)
  56. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/linux/${APP_ID}.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  57. if("${CMAKE_SYSTEM}" MATCHES "Linux")
  58. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/linux/${APP_ID}.policy DESTINATION ${CMAKE_INSTALL_DATADIR}/polkit-1/actions)
  59. endif()
  60. install(FILES linux/${APP_ID}.appdata.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
  61. endif(UNIX AND NOT APPLE AND NOT HAIKU)
  62. if(APPLE)
  63. install(FILES macosx/keepassxc.icns DESTINATION ${DATA_INSTALL_DIR})
  64. endif()
  65. if(WIN32)
  66. install(FILES windows/qt.conf DESTINATION ${BIN_INSTALL_DIR})
  67. endif()
  68. install(FILES icons/application/256x256/apps/keepassxc.png DESTINATION ${DATA_INSTALL_DIR}/icons/application/256x256/apps)
  69. add_custom_target(icons)
  70. add_custom_command(TARGET icons
  71. COMMAND bash ./icons/minify.sh
  72. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  73. if(APPLE)
  74. add_custom_command(TARGET icons
  75. COMMAND png2icns macosx/keepassxc.icns icons/application/256x256/apps/keepassxc.png
  76. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  77. endif()
  78. # ICO for Windows
  79. add_custom_command(TARGET icons
  80. COMMAND bash ./windows/create-ico.sh icons/application/scalable/apps/keepassxc.svg windows/keepassxc.ico
  81. COMMAND bash ./windows/create-ico.sh icons/application/scalable/mimetypes/application-x-keepassxc.svg windows/keepassxc-kdbx.ico
  82. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})