Warning, /office/kexi/cmake/modules/KexiAddIconsRccFile.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 kexi_add_icons_rcc_file()
0019 macro(kexi_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/${KEXI_BASE_PATH}/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         BYPRODUCTS "${_QRC_FILE}"
0042         COMMAND ${Qt5Core_RCC_EXECUTABLE} --project -o "${CMAKE_CURRENT_BINARY_DIR}/${_target}.qrc"
0043         # avoid adding the .qrc file to rcc due to rcc misfeature
0044         COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/${_target}.qrc" "${_QRC_FILE}"
0045         DEPENDS "${_FILES}"
0046         SOURCES "${_FILES}"
0047         WORKING_DIRECTORY "${_BASE_DIR}"
0048         COMMENT "Building Qt resource file ${_QRC_FILE}"
0049         VERBATIM
0050     )
0051     add_dependencies(${_target}_build_qrc ${_target}_copy_icons)
0052 
0053     add_custom_target(${_target}_build_rcc
0054         BYPRODUCTS "${_RCC_FILE}"
0055         COMMAND ${Qt5Core_RCC_EXECUTABLE} --compress 9 --threshold 0 --binary
0056                 --output "${_RCC_FILE}" "${_QRC_FILE}"
0057         DEPENDS "${_QRC_FILE}" "${_FILES}"
0058         WORKING_DIRECTORY "${_BASE_DIR}"
0059         COMMENT "Building external Qt resource ${_RCC_FILE}"
0060         VERBATIM
0061     )
0062     add_dependencies(${_target}_build_rcc ${_target}_build_qrc)
0063 
0064     add_dependencies(${_parent_target} ${_target}_build_rcc)
0065 
0066     install(FILES
0067             ${_RCC_FILE}
0068             DESTINATION "${ICONS_INSTALL_DIR}"
0069     )
0070 
0071     add_update_file_target(
0072         TARGET update_${_target}
0073         COMMAND "${PROJECT_SOURCE_DIR}/cmake/modules/update_icon_list.sh"
0074                 ${_theme} icons/${_theme}/files.cmake
0075         FILE ${_target}_files.cmake
0076         SOURCES "${PROJECT_SOURCE_DIR}/cmake/modules/update_icon_list.sh"
0077     )
0078     add_dependencies(update_all_rcc update_${_target})
0079 
0080     unset(_BASE_DIR)
0081     unset(_QRC_FILE)
0082     unset(_RCC_FILE)
0083 endmacro()