summaryrefslogtreecommitdiffstats
path: root/KF5KirigamiMacros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'KF5KirigamiMacros.cmake')
-rw-r--r--KF5KirigamiMacros.cmake85
1 files changed, 85 insertions, 0 deletions
diff --git a/KF5KirigamiMacros.cmake b/KF5KirigamiMacros.cmake
new file mode 100644
index 00000000..175db954
--- /dev/null
+++ b/KF5KirigamiMacros.cmake
@@ -0,0 +1,85 @@
1
2include(CMakeParseArguments)
3include(ExternalProject)
4find_package(Git)
5
6
7function(kirigami_package_breeze_icons)
8 set(_multiValueArgs ICONS)
9 cmake_parse_arguments(ARG "" "" "${_multiValueArgs}" ${ARGN} )
10
11 if(NOT ARG_ICONS)
12 message(FATAL_ERROR "No ICONS argument given to kirigami_package_breeze_icons")
13 endif()
14
15 #include icons used by Kirigami components themselves
16 set(ARG_ICONS ${ARG_ICONS} go-next go-previous handle-left handle-right)
17
18 function(_find_breeze_icon icon varName)
19 #HACKY
20 SET(path "")
21 file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/48/${icon}.svg )
22
23 #seach in other sizes as well
24 if (NOT EXISTS ${path})
25 file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/32/${icon}.svg )
26 if (NOT EXISTS ${path})
27 file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/24/${icon}.svg )
28 if (NOT EXISTS ${path})
29 file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/22/${icon}.svg )
30 endif()
31 endif()
32 endif()
33 if (NOT EXISTS ${path})
34 return()
35 endif()
36
37 get_filename_component(path "${path}" REALPATH)
38
39 SET(${varName} ${path} PARENT_SCOPE)
40 endfunction()
41
42 if (BREEZEICONS_DIR AND NOT EXISTS ${BREEZEICONS_DIR})
43 message(FATAL_ERROR "BREEZEICONS_DIR variable does not point to existing dir: \"${BREEZEICONS_DIR}\"")
44 endif()
45
46 set(_BREEZEICONS_DIR "${BREEZEICONS_DIR}")
47
48 #FIXME: this is a terrible hack
49 if(NOT _BREEZEICONS_DIR)
50 set(_BREEZEICONS_DIR "${CMAKE_BINARY_DIR}/breeze-icons/src/breeze-icons")
51
52 # replacement for ExternalProject_Add not yet working
53 # first time config?
54 if (NOT EXISTS ${_BREEZEICONS_DIR})
55 execute_process(COMMAND ${GIT_EXECUTABLE} clone --depth 1 git://anongit.kde.org/breeze-icons.git ${_BREEZEICONS_DIR})
56 endif()
57
58 # external projects are only pulled at make time, not configure time
59 # so this is too late to work with the _find_breeze_icon() method
60 # _find_breeze_icon() would need to be turned into a target/command
61 if (FALSE)
62 ExternalProject_Add(
63 breeze-icons
64 PREFIX breeze-icons
65 GIT_REPOSITORY git://anongit.kde.org/breeze-icons.git
66 CONFIGURE_COMMAND ""
67 BUILD_COMMAND ""
68 INSTALL_COMMAND ""
69 LOG_DOWNLOAD ON
70 )
71 endif()
72 endif()
73
74 message (STATUS "Found external breeze icons:")
75 foreach(_iconName ${ARG_ICONS})
76 set(_iconPath "")
77 _find_breeze_icon(${_iconName} _iconPath)
78 message (STATUS ${_iconPath})
79 if (EXISTS ${_iconPath})
80 install(FILES ${_iconPath} DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kirigami/icons/ RENAME ${_iconName}.svg)
81 endif()
82
83 endforeach()
84endfunction()
85