Warning, /libraries/kreport/cmake/modules/KReportAddIconsRccFile.cmake is written in an unsupported language. File is not indexed.

0001 # Copyright (C) 2016 Jarosław Staniek <staniek@kde.org>
0002 #
0003 # Redistribution and use is allowed according to the terms of the BSD license.
0004 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
0005 
0006 add_custom_target(update_all_rcc
0007     COMMENT "Updating all file lists for rcc icons files"
0008 )
0009 
0010 # Builds and install an rcc file with icons.
0011 # - resource subdirectory in the current build subdir is created
0012 # - ${_target}.qrc is created based on icons/${_theme}/files.cmake
0013 # - ${_target}.rcc is generated using rcc-qt5
0014 # - if _prefix is not empty, icons are placed in icons/${_prefix}/${_theme} path (useful for plugins)
0015 # - dependency for the parent target ${_parent_target} is added
0016 # - the .rcc file is installed to ${ICONS_INSTALL_DIR}
0017 # - update_${_target} target is added for requesting update of icons/${_theme}/files.cmake
0018 # - adds a update_all_rcc target that executes commands for all targets created with kreport_add_icons_rcc_file()
0019 macro(kreport_add_icons_rcc_file _target _parent_target _theme _prefix)
0020     set(_BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}/resource)
0021     set(_QRC_FILE "${_BASE_DIR}/${_target}.qrc")
0022     set(_RCC_DIR "${CMAKE_BINARY_DIR}/bin/data/${KREPORT_BASE_NAME_LOWER}/icons")
0023     set(_RCC_FILE "${_RCC_DIR}/${_target}.rcc")
0024     include(icons/${_theme}/files.cmake)
0025 
0026     add_custom_target(${_target}_copy_icons
0027         COMMAND ${CMAKE_COMMAND} -E remove_directory ${_BASE_DIR}
0028         COMMAND ${CMAKE_COMMAND} -E make_directory ${_BASE_DIR}
0029         COMMAND ${CMAKE_COMMAND} -E make_directory ${_RCC_DIR}
0030         COMMAND ${CMAKE_COMMAND} -E copy_directory icons/${_theme} ${_BASE_DIR}/icons/${_prefix}/${_theme}
0031         COMMAND ${CMAKE_COMMAND} -E remove -f ${_BASE_DIR}/CMakeLists.txt
0032         COMMAND ${CMAKE_COMMAND} -E remove -f ${_BASE_DIR}/icons/${_prefix}/${_theme}/files.cmake
0033         DEPENDS "${_FILES}"
0034         SOURCES "${_FILES}"
0035         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
0036         COMMENT "Copying icon files to ${_BASE_DIR}"
0037         VERBATIM
0038     )
0039 
0040     add_custom_target(${_target}_build_qrc
0041         COMMAND ${Qt5Core_RCC_EXECUTABLE} --project -o "${CMAKE_CURRENT_BINARY_DIR}/${_target}.qrc"
0042         # avoid adding the .qrc file to rcc due to rcc misfeature
0043         COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/${_target}.qrc" "${_QRC_FILE}"
0044         DEPENDS "${_FILES}"
0045         SOURCES "${_FILES}"
0046         WORKING_DIRECTORY "${_BASE_DIR}"
0047         COMMENT "Building Qt resource file ${_QRC_FILE}"
0048         VERBATIM
0049     )
0050     add_dependencies(${_target}_build_qrc ${_target}_copy_icons)
0051 
0052     add_custom_target(${_target}_build_rcc
0053         COMMAND ${Qt5Core_RCC_EXECUTABLE} --compress 9 --threshold 0 --binary
0054                 --output "${_RCC_FILE}" "${_QRC_FILE}"
0055         DEPENDS "${_QRC_FILE}" "${_FILES}"
0056         WORKING_DIRECTORY "${_BASE_DIR}"
0057         COMMENT "Building external Qt resource ${_RCC_FILE}"
0058         VERBATIM
0059     )
0060     add_dependencies(${_target}_build_rcc ${_target}_build_qrc)
0061 
0062     add_dependencies(${_parent_target} ${_target}_build_rcc)
0063 
0064     install(FILES
0065             ${_RCC_FILE}
0066             DESTINATION "${ICONS_INSTALL_DIR}"
0067     )
0068 
0069     add_update_file_target(
0070         TARGET update_${_target}
0071         COMMAND "${PROJECT_SOURCE_DIR}/cmake/modules/update_icon_list.sh"
0072                 ${_theme} icons/${_theme}/files.cmake
0073         FILE ${_target}_files.cmake
0074         SOURCES "${PROJECT_SOURCE_DIR}/cmake/modules/update_icon_list.sh"
0075     )
0076     add_dependencies(update_all_rcc update_${_target})
0077 
0078     unset(_BASE_DIR)
0079     unset(_QRC_FILE)
0080     unset(_RCC_FILE)
0081 endmacro()
0082 
0083 # Convenience macro for plugin icons. Icons are places in a path that contains _plugin_target.
0084 # For example, icons/org.kde.kreport.barcode/breeze/actions/16/kreport-barcode-element.svg.
0085 # This helps to make plugins not conflicting.
0086 macro(kreport_add_plugin_icons_rcc_file _plugin_target _theme)
0087     kreport_add_icons_rcc_file(${_plugin_target}_${_theme} ${_plugin_target} ${_theme} ${_plugin_target})
0088 endmacro()