not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / cursors / src / cursors.cmake
blob9c0ef63ae33a8a5cb225627044f381c6e2753d44
1 macro(add_cursor cursor color theme dpi)
2     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/oxy-${theme}/svg/${cursor}.svg
3                        DEPENDS ${MAKE_SVG} ${CMAKE_CURRENT_SOURCE_DIR}/colors.in ${SVGDIR}/${cursor}.svg
4                        COMMAND ${CMAKE_COMMAND} -Dconfig=${CMAKE_CURRENT_SOURCE_DIR}/colors.in
5                                                 -Dinput=${SVGDIR}/${cursor}.svg
6                                                 -Doutput=${CMAKE_BINARY_DIR}/oxy-${theme}/svg/${cursor}.svg
7                                                 -P ${MAKE_SVG}
8                       )
9     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/oxy-${theme}/png/${cursor}.png
10                        DEPENDS ${CMAKE_BINARY_DIR}/oxy-${theme}/svg/${cursor}.svg
11                        COMMAND ${INKSCAPE} --without-gui --export-dpi=${dpi}
12                                            --export-png=${CMAKE_BINARY_DIR}/oxy-${theme}/png/${cursor}.png
13                                            ${CMAKE_BINARY_DIR}/oxy-${theme}/svg/${cursor}.svg
14                       )
15 endmacro(add_cursor)
17 macro(add_x_cursor theme cursor dpi)
18     set(inputs)
19     foreach(png ${${cursor}_inputs})
20         list(APPEND inputs ${CMAKE_BINARY_DIR}/oxy-${theme}/png/${png})
21     endforeach(png)
22     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/oxy-${theme}/config/${cursor}.in
23                        DEPENDS ${MAKE_CONFIG} ${CONFIGDIR}/${cursor}.in
24                        COMMAND ${CMAKE_COMMAND} -Dconfig=${CONFIGDIR}/${cursor}.in
25                                                 -Doutput=${CMAKE_BINARY_DIR}/oxy-${theme}/config/${cursor}.in
26                                                 -Ddpi=${dpi}
27                                                 -P ${MAKE_CONFIG}
28                       )
29     if(NOT WIN32)
30     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/oxy-${theme}/cursors/${cursor}
31                        DEPENDS ${inputs} ${CMAKE_BINARY_DIR}/oxy-${theme}/config/${cursor}.in
32                        COMMAND ${XCURSORGEN} -p ${CMAKE_BINARY_DIR}/oxy-${theme}/png
33                                              ${CMAKE_BINARY_DIR}/oxy-${theme}/config/${cursor}.in
34                                              ${CMAKE_BINARY_DIR}/oxy-${theme}/cursors/${cursor}
35                       )
36     else(NOT WIN32)
37     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/oxy-${theme}/cursors/${cursor}
38                        DEPENDS ${inputs} ${CMAKE_BINARY_DIR}/oxy-${theme}/config/${cursor}.in
39                        COMMAND "${CMAKE_SOURCE_DIR}/wincursor.py" ${CMAKE_BINARY_DIR}/oxy-${theme}/png
40                                              ${CMAKE_BINARY_DIR}/oxy-${theme}/config/${cursor}.in
41                                              ${CMAKE_BINARY_DIR}/wincursors/oxy-${theme}
42                                              ${CMAKE_BINARY_DIR}/oxy-${theme}/cursors/${cursor}
43                       )
44     endif(NOT WIN32)
45 endmacro(add_x_cursor)
47 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages)
48 macro(add_theme color theme dpi)
49     file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/oxy-${theme}/png)
50     file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/oxy-${theme}/svg)
51     file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/oxy-${theme}/config)
52     file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/oxy-${theme}/cursors)
53     if(WIN32)
54     file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/wincursors/oxy-${theme})
55     endif(WIN32)
56     set(${theme}_cursors)
57     foreach(svg ${SVGS})
58         string(REGEX REPLACE ".*/" "" cursor ${svg})
59         string(REGEX REPLACE "[.]svg" "" cursor ${cursor})
60         add_cursor(${cursor} ${color} ${theme} ${dpi})
61     endforeach(svg)
62     foreach(cursor ${CURSORS})
63         add_x_cursor(${theme} ${cursor} ${dpi})
64         list(APPEND ${theme}_cursors ${CMAKE_BINARY_DIR}/oxy-${theme}/cursors/${cursor})
65     endforeach(cursor)
66     add_custom_target(theme-${theme} ALL DEPENDS ${${theme}_cursors})
67     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/oxy-${theme}/index.theme
68                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/index.theme
69                        COMMAND ${CMAKE_COMMAND} -E copy_if_different
70                                                    ${CMAKE_CURRENT_SOURCE_DIR}/index.theme
71                                                    ${CMAKE_BINARY_DIR}/oxy-${theme}/index.theme
72                       )
73     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.tar.bz2
74                        DEPENDS ${${theme}_cursors} ${CMAKE_BINARY_DIR}/oxy-${theme}/index.theme
75                        COMMAND ${TAR} cjf ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.tar.bz2
76                                       oxy-${theme}/cursors
77                                       oxy-${theme}/index.theme
78                        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
79                       )
80     add_custom_target(package-${theme} DEPENDS ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.tar.bz2)
81 endmacro(add_theme)