2 # Phonon helper macros:
4 # macro (phonon_add_executable _target)
5 # macro (PHONON_ADD_UNIT_TEST _test_NAME)
6 # macro (PHONON_UPDATE_ICONCACHE)
7 # macro (PHONON_UPDATE_ICONCACHE)
8 # macro (_PHONON_ADD_ICON_INSTALL_RULE _install_SCRIPT _install_PATH _group _orig_NAME _install_NAME _l10n_SUBDIR)
9 # macro (PHONON_INSTALL_ICONS _defaultpath )
11 set(_global_add_executable_param)
13 set(_global_add_executable_param MACOSX_BUNDLE)
16 # no WIN32 here - all executables are command line executables
17 set(_global_add_executable_param)
20 macro(phonon_add_executable _target)
22 automoc4_add_executable(${_target} ${_global_add_executable_param} ${_srcs})
23 endmacro(phonon_add_executable _target)
25 macro (PHONON_ADD_UNIT_TEST _test_NAME)
28 list(GET ${_srcList} 0 first_PARAM)
29 set(_add_executable_param ${_global_add_executable_param})
30 if(${first_PARAM} STREQUAL "NOGUI")
32 set(_add_executable_param)
33 endif(${first_PARAM} STREQUAL "NOGUI")
35 if (NOT PHONON_BUILD_TESTS)
36 set(_add_executable_param ${_add_executable_param} EXCLUDE_FROM_ALL)
37 endif (NOT PHONON_BUILD_TESTS)
39 automoc4_add_executable(${_test_NAME} ${_add_executable_param} ${_srcList})
41 if(NOT PHONON_TEST_OUTPUT)
42 set(PHONON_TEST_OUTPUT plaintext)
43 endif(NOT PHONON_TEST_OUTPUT)
44 set(PHONON_TEST_OUTPUT ${PHONON_TEST_OUTPUT} CACHE STRING "The output to generate when running the QTest unit tests")
47 foreach(_filename ${_srcList})
49 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_filename}")
50 file(READ ${_filename} file_CONTENT)
51 string(REGEX MATCH "QTEST_(KDE)?MAIN" using_qtest "${file_CONTENT}")
52 endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_filename}")
53 endif(NOT using_qtest)
56 set(_executable ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME})
57 if (Q_WS_MAC AND NOT _nogui)
58 set(_executable ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME}.app/Contents/MacOS/${_test_NAME})
59 else (Q_WS_MAC AND NOT _nogui)
60 # Use .shell wrapper where available, to use uninstalled libs.
62 # set(_executable ${_executable}.shell)
64 endif (Q_WS_MAC AND NOT _nogui)
66 if (using_qtest AND PHONON_TEST_OUTPUT STREQUAL "xml")
67 add_test( ${_test_NAME} ${_executable} -xml -o ${_test_NAME}.tml)
68 else (using_qtest AND PHONON_TEST_OUTPUT STREQUAL "xml")
69 add_test( ${_test_NAME} ${_executable} )
70 endif (using_qtest AND PHONON_TEST_OUTPUT STREQUAL "xml")
72 if (NOT MSVC_IDE) #not needed for the ide
73 # if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests
74 if (NOT PHONON_BUILD_TESTS)
75 get_directory_property(_buildtestsAdded BUILDTESTS_ADDED)
76 if(NOT _buildtestsAdded)
77 add_custom_target(buildtests)
78 set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE)
79 endif(NOT _buildtestsAdded)
80 add_dependencies(buildtests ${_test_NAME})
81 endif (NOT PHONON_BUILD_TESTS)
83 endmacro (PHONON_ADD_UNIT_TEST)
85 macro (PHONON_UPDATE_ICONCACHE)
86 # Update mtime of hicolor icon theme dir.
87 # We don't always have touch command (e.g. on Windows), so instead create
88 # and delete a temporary file in the theme dir.
90 set(DESTDIR_VALUE \"\$ENV{DESTDIR}\")
91 if (NOT DESTDIR_VALUE)
92 file(WRITE \"${ICON_INSTALL_DIR}/hicolor/temp.txt\" \"update\")
93 file(REMOVE \"${ICON_INSTALL_DIR}/hicolor/temp.txt\")
94 endif (NOT DESTDIR_VALUE)
96 endmacro (PHONON_UPDATE_ICONCACHE)
98 # a "map" of short type names to the directories
99 # unknown names should give empty results
100 # KDE 3 compatibility
101 set(_PHONON_ICON_GROUP_mime "mimetypes")
102 set(_PHONON_ICON_GROUP_filesys "places")
103 set(_PHONON_ICON_GROUP_device "devices")
104 set(_PHONON_ICON_GROUP_app "apps")
105 set(_PHONON_ICON_GROUP_action "actions")
106 # KDE 4 / icon naming specification compatibility
107 set(_PHONON_ICON_GROUP_mimetypes "mimetypes")
108 set(_PHONON_ICON_GROUP_places "places")
109 set(_PHONON_ICON_GROUP_devices "devices")
110 set(_PHONON_ICON_GROUP_apps "apps")
111 set(_PHONON_ICON_GROUP_actions "actions")
112 set(_PHONON_ICON_GROUP_categories "categories")
113 set(_PHONON_ICON_GROUP_status "status")
114 set(_PHONON_ICON_GROUP_emblems "emblems")
115 set(_PHONON_ICON_GROUP_emotes "emotes")
116 set(_PHONON_ICON_GROUP_animations "animations")
117 set(_PHONON_ICON_GROUP_intl "intl")
119 # a "map" of short theme names to the theme directory
120 set(_PHONON_ICON_THEME_ox "oxygen")
121 set(_PHONON_ICON_THEME_cr "crystalsvg")
122 set(_PHONON_ICON_THEME_lo "locolor")
123 set(_PHONON_ICON_THEME_hi "hicolor")
125 macro (_PHONON_ADD_ICON_INSTALL_RULE _install_SCRIPT _install_PATH _group _orig_NAME _install_NAME _l10n_SUBDIR)
127 # if the string doesn't match the pattern, the result is the full string, so all three have the same content
128 if (NOT ${_group} STREQUAL ${_install_NAME} )
129 set(_icon_GROUP ${_PHONON_ICON_GROUP_${_group}})
131 set(_icon_GROUP "actions")
132 endif(NOT _icon_GROUP)
133 # message(STATUS "icon: ${_current_ICON} size: ${_size} group: ${_group} name: ${_name} l10n: ${_l10n_SUBDIR}")
134 install(FILES ${_orig_NAME} DESTINATION ${_install_PATH}/${_icon_GROUP}/${_l10n_SUBDIR}/ RENAME ${_install_NAME} )
135 endif (NOT ${_group} STREQUAL ${_install_NAME} )
137 endmacro (_PHONON_ADD_ICON_INSTALL_RULE)
140 macro (PHONON_INSTALL_ICONS _defaultpath )
142 # the l10n-subdir if language given as second argument (localized icon)
145 set(_l10n_SUBDIR l10n/${_lang})
147 set(_l10n_SUBDIR ".")
150 # first the png icons
151 file(GLOB _icons *.png)
152 foreach (_current_ICON ${_icons} )
153 # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
154 string(REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" _dummy "${_current_ICON}")
155 set(_type "${CMAKE_MATCH_1}")
156 set(_size "${CMAKE_MATCH_2}")
157 set(_group "${CMAKE_MATCH_3}")
158 set(_name "${CMAKE_MATCH_4}")
160 set(_theme_GROUP ${_PHONON_ICON_THEME_${_type}})
162 _PHONON_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
163 ${_defaultpath}/${_theme_GROUP}/${_size}x${_size}
164 ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR})
166 endforeach (_current_ICON)
169 file(GLOB _icons *.mng)
170 foreach (_current_ICON ${_icons} )
171 # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
172 string(REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" _dummy "${_current_ICON}")
173 set(_type "${CMAKE_MATCH_1}")
174 set(_size "${CMAKE_MATCH_2}")
175 set(_group "${CMAKE_MATCH_3}")
176 set(_name "${CMAKE_MATCH_4}")
178 set(_theme_GROUP ${_PHONON_ICON_THEME_${_type}})
180 _PHONON_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
181 ${_defaultpath}/${_theme_GROUP}/${_size}x${_size}
182 ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR})
184 endforeach (_current_ICON)
186 # and now the svg icons
187 file(GLOB _icons *.svgz)
188 foreach (_current_ICON ${_icons} )
189 # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
190 string(REGEX MATCH "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" _dummy "${_current_ICON}")
191 set(_type "${CMAKE_MATCH_1}")
192 set(_group "${CMAKE_MATCH_2}")
193 set(_name "${CMAKE_MATCH_3}")
195 set(_theme_GROUP ${_PHONON_ICON_THEME_${_type}})
197 _PHONON_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
198 ${_defaultpath}/${_theme_GROUP}/scalable
199 ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR})
201 endforeach (_current_ICON)
203 phonon_update_iconcache()
205 endmacro (PHONON_INSTALL_ICONS)