Warning, /frameworks/kirigami/KF5Kirigami2Macros.cmake is written in an unsupported language. File is not indexed.

0001 include(CMakeParseArguments)
0002 include(ExternalProject)
0003 
0004 
0005 function(kirigami_package_breeze_icons)
0006     set(_multiValueArgs ICONS)
0007     cmake_parse_arguments(ARG "" "" "${_multiValueArgs}" ${ARGN} )
0008 
0009     if(NOT ARG_ICONS)
0010         message(FATAL_ERROR "No ICONS argument given to kirigami_package_breeze_icons")
0011     endif()
0012 
0013     #include icons used by Kirigami components themselves
0014     set(ARG_ICONS ${ARG_ICONS} go-next go-previous go-up handle-sort overflow-menu-left overflow-menu-right go-next-symbolic go-next-symbolic-rtl go-previous-symbolic go-previous-symbolic-rtl overflow-menu user view-left-new view-right-new view-left-close view-right-close dialog-positive dialog-warning dialog-error dialog-information dialog-close globe mail-sent tools-report-bug)
0015 
0016     function(_find_breeze_icon icon varName)
0017         #HACKY
0018         SET(path "")
0019         file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/48/${icon}.svg )
0020 
0021         #search in other sizes as well
0022         if (path STREQUAL "")
0023             file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/32/${icon}.svg )
0024             if (path STREQUAL "")
0025                 file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/22/${icon}.svg )
0026                 if (path STREQUAL "")
0027                     file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/16/${icon}.svg )
0028                 endif()
0029             endif()
0030         endif()
0031         if (path STREQUAL "")
0032             file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/symbolic/${icon}.svg )
0033         endif()
0034         if (path STREQUAL "")
0035             return()
0036         endif()
0037 
0038         list(LENGTH path _count_paths)
0039         if (_count_paths GREATER 1)
0040             message(WARNING "Found more than one version of '${icon}': ${path}")
0041         endif()
0042         list(GET path 0 path)
0043         get_filename_component(path "${path}" REALPATH)
0044 
0045         SET(${varName} ${path} PARENT_SCOPE)
0046     endfunction()
0047 
0048     if (BREEZEICONS_DIR AND NOT EXISTS ${BREEZEICONS_DIR})
0049         message(FATAL_ERROR "BREEZEICONS_DIR variable does not point to existing dir: \"${BREEZEICONS_DIR}\"")
0050     endif()
0051 
0052     set(_BREEZEICONS_DIR "${BREEZEICONS_DIR}")
0053 
0054     #FIXME: this is a terrible hack
0055     if(NOT _BREEZEICONS_DIR)
0056         set(_BREEZEICONS_DIR "${CMAKE_BINARY_DIR}/breeze-icons/src/breeze-icons")
0057 
0058         # replacement for ExternalProject_Add not yet working
0059         # first time config?
0060         if (NOT EXISTS ${_BREEZEICONS_DIR})
0061             find_package(Git)
0062             execute_process(COMMAND ${GIT_EXECUTABLE} clone --depth 1 https://invent.kde.org/frameworks/breeze-icons.git ${_BREEZEICONS_DIR})
0063         endif()
0064 
0065         # external projects are only pulled at make time, not configure time
0066         # so this is too late to work with the _find_breeze_icon() method
0067         # _find_breeze_icon() would need to be turned into a target/command
0068         if (FALSE)
0069         ExternalProject_Add(
0070             breeze-icons
0071             PREFIX breeze-icons
0072             GIT_REPOSITORY https://invent.kde.org/frameworks/breeze-icons.git
0073             CONFIGURE_COMMAND ""
0074             BUILD_COMMAND ""
0075             INSTALL_COMMAND ""
0076             LOG_DOWNLOAD ON
0077         )
0078         endif()
0079     endif()
0080 
0081     message (STATUS "Found external breeze icons:")
0082     foreach(_iconName ${ARG_ICONS})
0083         set(_iconPath "")
0084         _find_breeze_icon(${_iconName} _iconPath)
0085         message (STATUS ${_iconPath})
0086         if (EXISTS ${_iconPath})
0087             install(FILES ${_iconPath} DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kirigami.2/icons/ RENAME ${_iconName}.svg)
0088         endif()
0089     endforeach()
0090 
0091     #generate an index.theme that qiconloader can understand
0092     file(WRITE ${CMAKE_BINARY_DIR}/index.theme "[Icon Theme]\nName=Breeze\nDirectories=icons\n[icons]\nSize=32\nType=Scalable")
0093     install(FILES ${CMAKE_BINARY_DIR}/index.theme DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kirigami.2/)
0094 endfunction()
0095