Warning, /libraries/kproperty/cmake/modules/KPropertyAddIconsRccFile.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 kproperty_add_icons_rcc_file()
0019 macro(kproperty_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/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 #COMMAND ${CMAKE_COMMAND} -E remove -f ${_QRC_FILE}
0056 DEPENDS "${_QRC_FILE}" "${_FILES}"
0057 WORKING_DIRECTORY "${_BASE_DIR}"
0058 COMMENT "Building external Qt resource ${_RCC_FILE}"
0059 VERBATIM
0060 )
0061 add_dependencies(${_target}_build_rcc ${_target}_build_qrc)
0062
0063 add_dependencies(${_parent_target} ${_target}_build_rcc)
0064
0065 install(FILES
0066 ${_RCC_FILE}
0067 DESTINATION "${ICONS_INSTALL_DIR}"
0068 )
0069
0070 add_update_file_target(
0071 TARGET update_${_target}
0072 COMMAND "${PROJECT_SOURCE_DIR}/cmake/modules/update_icon_list.sh"
0073 ${_theme} icons/${_theme}/files.cmake
0074 FILE ${_target}_files.cmake
0075 SOURCES "${PROJECT_SOURCE_DIR}/cmake/modules/update_icon_list.sh"
0076 )
0077 add_dependencies(update_all_rcc update_${_target})
0078
0079 unset(_BASE_DIR)
0080 unset(_QRC_FILE)
0081 unset(_RCC_FILE)
0082 endmacro()