1 # - Common macros for Tp-Qt4
3 # Copyright (c) 2010, Collabora Ltd. <http://www.collabora.co.uk/>
5 # Redistribution and use is allowed according to the terms of the BSD license.
8 # These macros/functions are not exported - they are meant for internal usage into Telepathy-Qt4's build system.
10 # Preamble: How dynamic generators are handled with the CMake build system.
11 # Telepathy-Qt4 strongly relies upon lots of files generated at build time through some python programs, found
12 # in tools/. To avoid developers the struggle of handling those manually, a set of convenience macros have been
13 # created to handle them with the correct dependencies. Each of those macros takes a target name as a first argument
14 # and creates a target with that exact name. In a similar fashion, in the last argument you can specify a list
15 # of targets the generated target will depend on. This way, you can handle transparently dependencies between
16 # generated files, while the dirty stuff is done for you in the background.
18 # macro TPQT4_EXTRACT_DEPENDS (tpqt4_other tpqt4_depends)
19 # Internal macro used to extract arguments from ARGN
21 # function TPQT4_CREATE_MOC_COMMAND_TARGET_DEPS(inputfile outputfile moc_flags moc_options target_dependencies ...)
22 # This function behaves exactly like qt4_create_moc_command, but creates a custom target for the
23 # moc file generation, allowing to specify a list of targets the generated moc target will depend on.
24 # Just like qt4_create_moc_command, it is an internal macro and it's not meant to be used explicitely.
26 # function TPQT4_GENERATE_MOC_I(inputfile outputfile)
27 # This function behaves exactly like qt4_generate_moc, but it generates moc files with the -i option,
28 # which disables the generation of an #include directive. This macro has to be used always when building
29 # Tp-Qt4 internals due to the internal header files restrictions.
31 # function TPQT4_GENERATE_MOC_I_TARGET_DEPS(inputfile outputfile target_dependencies ...)
32 # This function acts as an overload to QT4_GENERATE_MOC_I: it does exactly the same thing, but creates a
33 # custom target for the moc file generation, and adds target_dependencies to it as dependencies.
35 # function TPQT4_GENERATE_MOCS(sourcefile ...)
36 # Generates mocs from a list of header files. You usually want to use this function when building tests
37 # or examples. Please remember the list of the header files passed to this function MUST be added to the
40 # function TPQT4_CLIENT_GENERATOR(spec group pretty_include namespace [arguments] [DEPENDS dependencies ...])
41 # This function takes care of invoking qt4-client-gen.py with the correct arguments, which generates
42 # headers out of specs. spec is the name of the spec headers will be generated from, group represents
43 # the spec's group, pretty_include is the name of the capitalized header (for example ClientGenerator),
44 # namespace is the C++ namespace the generated header will belong to. This function also accepts
45 # as an optional last argument a list of additional command line arguments which will be passed to
46 # qt4-client-gen.py upon execution. After issuing DEPENDS in the last argument you can pass a list of targets
47 # the generated target will depend on.
49 # function TPQT4_FUTURE_CLIENT_GENERATOR(spec namespace [arguments] [DEPENDS dependencies ...])
50 # Same as tpqt4_client_generator, but for future interfaces
52 # function TPQT4_GENERATE_MANAGER_FILE(MANAGER_FILE OUTPUT_FILENAME DEPEND_FILENAME)
53 # This function takes care of invoking manager-file.py with the correct arguments. The first argument is the
54 # path to the manager-file.py file which should be used, the second is the output filename of the manager,
55 # and the third is the path to the file which depends on the generated manager file.
57 # function TPQT4_XINCLUDATOR (TARGET_NAME INPUT_FILE OUTPUT_FILE [additional_arguments ...] [DEPENDS dependencies ...])
58 # This function takes care of invoking xincludator.py with the correct arguments. TARGET_NAME is the name of
59 # the generated target (see preamble), INPUT_FILE is the input spec file, OUTPUT_FILE is the filename
60 # the generated file will be saved to. This function also accepts as an optional last argument a list of
61 # additional command line arguments which will be passed to xincludator upon execution.
62 # After issuing DEPENDS in the last argument you can pass a list of targets the generated target will depend on.
64 # function TPQT4_CONSTANTS_GEN (TARGET_NAME SPEC_XML OUTPUT_FILE [additional_arguments ...] [DEPENDS dependencies ...])
65 # This function takes care of invoking qt4-constants-gen.py with the correct arguments. TARGET_NAME is the name of
66 # the generated target (see preamble), SPEC_XML is the spec input file, OUTPUT_FILE is the filename
67 # the generated file will be saved to. This function also accepts as an optional last argument a list of
68 # additional command line arguments which will be passed to qt4-constants-gen.py upon execution.
69 # After issuing DEPENDS in the last argument you can pass a list of targets the generated target will depend on.
71 # function TPQT4_TYPES_GEN (TARGET_NAME SPEC_XML OUTFILE_DECL OUTFILE_IMPL NAMESPACE
72 # REAL_INCLUDE PRETTY_INCLUDE [additional_arguments ...] [DEPENDS dependencies ...])
73 # This function takes care of invoking qt4-types-gen.py with the correct arguments. TARGET_NAME is the name of
74 # the generated target (see preamble), SPEC_XML is the input spec file, OUTFILE_DECL is the filename
75 # the header of the generated file will be saved to, OUTFILE_IMPL is the filename the implementation of the
76 # generated file will be saved to, NAMESPACE is the C++ namespace the generated header will belong to,
77 # REAL_INCLUDE is the real include file you want to use, PRETTY_INCLUDE is the name of the capitalized header
78 # (for example ClientGenerator).
79 # This function also accepts as an optional last argument a list of additional command line arguments
80 # which will be passed to qt4-constants-gen.py upon execution.
81 # After issuing DEPENDS in the last argument you can pass a list of targets the generated target will depend on.
83 # macro TPQT4_ADD_GENERIC_UNIT_TEST (fancyName name [libraries ...])
84 # This macro takes care of building and adding a generic unit test to the automatic CTest suite. The requirement
85 # for using this macro is to have the unit test contained in a single source file named ${name}.cpp. fancyName will
86 # be used as the test and target's name, and you can specify as a third and optional argument a set of additional
87 # libraries the target will link to.
89 # macro TPQT4_ADD_DBUS_UNIT_TEST (fancyName name [libraries ...])
90 # This macro takes care of building and adding an unit test requiring DBus emulation to the automatic
91 # CTest suite. The requirement for using this macro is to have the unit test contained in a single
92 # source file named ${name}.cpp. fancyName will be used as the test and target's name, and you can specify as a third
93 # and optional argument a set of additional libraries the target will link to. Please remember that you need to
94 # set up the DBus environment by calling TPQT4_SETUP_DBUS_TEST_ENVIRONMENT BEFORE you call this macro.
96 # macro _TPQT4_ADD_CHECK_TARGETS (fancyName name command [args])
97 # This is an internal macro which is meant to be used by TPQT4_ADD_DBUS_UNIT_TEST and TPQT4_ADD_GENERIC_UNIT_TEST.
98 # It takes care of generating a check target for each test method available (currently normal execution, valgrind and
99 # callgrind). This macro accepts the same arguments as the add test macros, but accepts a command and a list of
100 # arguments for running the test instead of the link libraries. However, you are not meant to call this macro from
101 # your CMakeLists.txt files.
103 # function TPQT4_SETUP_DBUS_TEST_ENVIRONMENT ()
104 # This function MUST be called before calling TPQT4_ADD_DBUS_UNIT_TEST. It takes care of preparing the test
105 # environment for DBus tests and generating the needed files.
108 MACRO (TPQT4_EXTRACT_DEPENDS _tpqt4_other _tpqt4_depends)
110 SET(${_tpqt4_depends})
111 SET(_TPQT4_DOING_DEPENDS FALSE)
112 FOREACH(_currentArg ${ARGN})
113 IF ("${_currentArg}" STREQUAL "DEPENDS")
114 SET(_TPQT4_DOING_DEPENDS TRUE)
115 ELSE ("${_currentArg}" STREQUAL "DEPENDS")
116 IF(_TPQT4_DOING_DEPENDS)
117 LIST(APPEND ${_tpqt4_depends} "${_currentArg}")
118 ELSE(_TPQT4_DOING_DEPENDS)
119 LIST(APPEND ${_tpqt4_other} "${_currentArg}")
120 ENDIF(_TPQT4_DOING_DEPENDS)
121 ENDIF ("${_currentArg}" STREQUAL "DEPENDS")
122 ENDFOREACH(_currentArg)
123 ENDMACRO (TPQT4_EXTRACT_DEPENDS)
125 # helper function to set up a moc rule
126 FUNCTION (TPQT4_CREATE_MOC_COMMAND_TARGET_DEPS infile outfile moc_flags moc_options)
127 # For Windows, create a parameters file to work around command line length limit
128 GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
130 # Pass the parameters in a file. Set the working directory to
131 # be that containing the parameters file and reference it by
132 # just the file name. This is necessary because the moc tool on
133 # MinGW builds does not seem to handle spaces in the path to the
134 # file given with the @ syntax.
135 GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
137 SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
138 ENDIF(_moc_outfile_dir)
139 SET (_moc_parameters_file ${outfile}_parameters)
140 SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
141 FILE (REMOVE ${_moc_parameters_file})
142 FOREACH(arg ${_moc_parameters})
143 FILE (APPEND ${_moc_parameters_file} "${arg}\n")
145 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
146 COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
151 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
152 COMMAND ${QT_MOC_EXECUTABLE}
153 ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
157 add_custom_target(moc-${_moc_outfile_name} DEPENDS ${outfile})
158 add_dependencies(moc-${_moc_outfile_name} ${ARGN})
159 ENDFUNCTION (TPQT4_CREATE_MOC_COMMAND_TARGET_DEPS)
161 # add the -i option to QT4_GENERATE_MOC
162 function(TPQT4_GENERATE_MOC_I infile outfile)
163 qt4_get_moc_flags(moc_flags)
164 get_filename_component(abs_infile ${infile} ABSOLUTE)
165 qt4_create_moc_command(${abs_infile} ${outfile} "${moc_flags}" "-i")
166 set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
167 endfunction(TPQT4_GENERATE_MOC_I)
169 # same as tpqt4_generate_moc_i, but lets the caller specify a list of targets which the mocs should depend on
170 function(TPQT4_GENERATE_MOC_I_TARGET_DEPS infile outfile)
171 qt4_get_moc_flags(moc_flags)
172 get_filename_component(abs_infile ${infile} ABSOLUTE)
173 tpqt4_create_moc_command_target_deps(${abs_infile} ${outfile} "${moc_flags}" "-i" ${ARGN})
174 set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
175 endfunction(TPQT4_GENERATE_MOC_I_TARGET_DEPS)
177 # generates mocs for the passed list. The list should be added to the target's sources
178 function(tpqt4_generate_mocs)
179 file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/_gen" )
180 foreach(moc_src ${ARGN})
181 string(REPLACE ".h" ".moc.hpp" generated_file ${moc_src})
182 tpqt4_generate_moc_i(${CMAKE_CURRENT_SOURCE_DIR}/${moc_src} ${CMAKE_CURRENT_BINARY_DIR}/_gen/${generated_file})
183 macro_add_file_dependencies(${moc_src} ${CMAKE_CURRENT_BINARY_DIR}/_gen/${generated_file})
184 endforeach(moc_src ${ARGN})
185 endfunction(tpqt4_generate_mocs)
187 function(tpqt4_client_generator spec group pretty_include namespace)
188 tpqt4_extract_depends(client_generator_args client_generator_depends ${ARGN})
190 ${CMAKE_SOURCE_DIR}/tools/qt4-client-gen.py
192 --namespace=${namespace}
194 --headerfile=${CMAKE_CURRENT_BINARY_DIR}/_gen/cli-${spec}.h
195 --implfile=${CMAKE_CURRENT_BINARY_DIR}/_gen/cli-${spec}-body.hpp
196 --realinclude=TelepathyQt4/${spec}.h
197 --prettyinclude=TelepathyQt4/${pretty_include}
198 --specxml=${CMAKE_CURRENT_BINARY_DIR}/_gen/stable-spec.xml
199 --ifacexml=${CMAKE_CURRENT_BINARY_DIR}/_gen/spec-${spec}.xml
200 --extraincludes=${TYPES_INCLUDE}
201 --must-define=IN_TELEPATHY_QT4_HEADER
202 --visibility=TELEPATHY_QT4_EXPORT
203 ${client_generator_args})
204 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_gen/cli-${spec}.h ${CMAKE_CURRENT_BINARY_DIR}/_gen/cli-${spec}-body.hpp
205 COMMAND ${PYTHON_EXECUTABLE}
207 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
209 DEPENDS ${CMAKE_SOURCE_DIR}/tools/libqt4codegen.py
210 ${CMAKE_SOURCE_DIR}/tools/qt4-client-gen.py)
211 add_custom_target(generate_cli-${spec}-body DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_gen/cli-${spec}-body.hpp)
213 if (client_generator_depends)
214 add_dependencies(generate_cli-${spec}-body ${client_generator_depends})
215 endif (client_generator_depends)
217 tpqt4_generate_moc_i_target_deps(${CMAKE_CURRENT_BINARY_DIR}/_gen/cli-${spec}.h
218 ${CMAKE_CURRENT_BINARY_DIR}/_gen/cli-${spec}.moc.hpp
219 "generate_cli-${spec}-body")
220 list(APPEND telepathy_qt4_SRCS ${CMAKE_CURRENT_BINARY_DIR}/_gen/cli-${spec}.moc.hpp)
221 endfunction(tpqt4_client_generator spec group pretty_include namespace)
223 function(tpqt4_future_client_generator spec namespace)
224 tpqt4_extract_depends(future_client_generator_args future_client_generator_depends ${ARGN})
226 ${CMAKE_SOURCE_DIR}/tools/qt4-client-gen.py
227 --namespace=${namespace}
228 --typesnamespace=TpFuture
229 --headerfile=${CMAKE_CURRENT_BINARY_DIR}/_gen/future-${spec}.h
230 --implfile=${CMAKE_CURRENT_BINARY_DIR}/_gen/future-${spec}-body.hpp
231 --realinclude=TelepathyQt4/future-internal.h
232 --prettyinclude=TelepathyQt4/future-internal.h
233 --specxml=${CMAKE_CURRENT_BINARY_DIR}/_gen/future-spec.xml
234 --ifacexml=${CMAKE_CURRENT_BINARY_DIR}/_gen/future-${spec}.xml
235 --extraincludes=${TYPES_INCLUDE}
236 --extraincludes='<TelepathyQt4/Types>'
237 --extraincludes='<TelepathyQt4/future-internal.h>'
238 --visibility=TELEPATHY_QT4_NO_EXPORT
239 ${future_client_generator_args})
240 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_gen/future-${spec}.h ${CMAKE_CURRENT_BINARY_DIR}/_gen/future-${spec}-body.hpp
241 COMMAND ${PYTHON_EXECUTABLE}
243 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
245 DEPENDS ${CMAKE_SOURCE_DIR}/tools/libqt4codegen.py
246 ${CMAKE_SOURCE_DIR}/tools/qt4-client-gen.py)
247 add_custom_target(generate_future-${spec}-body DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_gen/future-${spec}-body.hpp)
249 if (future_client_generator_depends)
250 add_dependencies(generate_future-${spec}-body ${future_client_generator_depends})
251 endif (future_client_generator_depends)
253 tpqt4_generate_moc_i_target_deps(${CMAKE_CURRENT_BINARY_DIR}/_gen/future-${spec}.h
254 ${CMAKE_CURRENT_BINARY_DIR}/_gen/future-${spec}.moc.hpp
255 "generate_future-${spec}-body")
256 endfunction(tpqt4_future_client_generator spec namespace)
258 # This function is used for generating CM in various examples
259 function(tpqt4_generate_manager_file MANAGER_FILE OUTPUT_FILENAME DEPEND_FILENAME)
260 # make_directory is required, otherwise the command won't work!!
261 make_directory(${CMAKE_CURRENT_BINARY_DIR}/_gen)
262 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_gen/param-spec-struct.h
263 ${CMAKE_CURRENT_BINARY_DIR}/_gen/${OUTPUT_FILENAME}
265 COMMAND ${PYTHON_EXECUTABLE}
267 ARGS ${CMAKE_SOURCE_DIR}/tools/manager-file.py
271 DEPENDS ${CMAKE_SOURCE_DIR}/tools/manager-file.py)
273 set_source_files_properties(${DEPEND_FILENAME}
274 PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_gen/param-spec-struct.h)
275 endfunction(tpqt4_generate_manager_file MANAGER_FILE)
277 function(tpqt4_xincludator _TARGET_NAME _INPUT_FILE _OUTPUT_FILE)
278 tpqt4_extract_depends(xincludator_gen_args xincludator_gen_depends ${ARGN})
279 # Gather all .xml files in TelepathyQt4 and spec/ and make this target depend on those
280 file(GLOB depends_xml_files ${CMAKE_SOURCE_DIR}/TelepathyQt4/*.xml ${CMAKE_SOURCE_DIR}/spec/*.xml)
282 add_custom_command(OUTPUT ${_OUTPUT_FILE}
284 COMMAND ${PYTHON_EXECUTABLE}
286 ARGS ${CMAKE_SOURCE_DIR}/tools/xincludator.py
288 ${xincludator_gen_args}
291 DEPENDS ${CMAKE_SOURCE_DIR}/tools/xincludator.py
292 ${_INPUT_FILE} ${depends_xml_files})
293 add_custom_target(${_TARGET_NAME} DEPENDS ${_OUTPUT_FILE})
295 if (xincludator_gen_depends)
296 add_dependencies(${_TARGET_NAME} ${xincludator_gen_depends})
297 endif (xincludator_gen_depends)
298 endfunction(tpqt4_xincludator _TARGET_NAME _INPUT_FILE _OUTPUT_FILE)
300 function(tpqt4_constants_gen _TARGET_NAME _SPEC_XML _OUTFILE)
301 tpqt4_extract_depends(constants_gen_args constants_gen_depends ${ARGN})
302 # Gather all .xml files in TelepathyQt4 and spec/ and make this target depend on those
303 file(GLOB depends_xml_files ${CMAKE_SOURCE_DIR}/TelepathyQt4/*.xml ${CMAKE_SOURCE_DIR}/spec/*.xml)
305 add_custom_command(OUTPUT ${_OUTFILE}
307 COMMAND ${PYTHON_EXECUTABLE}
309 ARGS ${CMAKE_SOURCE_DIR}/tools/qt4-constants-gen.py
310 ${constants_gen_args}
311 --specxml=${_SPEC_XML}
314 DEPENDS ${CMAKE_SOURCE_DIR}/tools/libqt4codegen.py
315 ${CMAKE_SOURCE_DIR}/tools/qt4-constants-gen.py
316 ${_SPEC_XML} ${depends_xml_files})
317 add_custom_target(${_TARGET_NAME} DEPENDS ${_OUTFILE})
319 if (constants_gen_depends)
320 add_dependencies(${_TARGET_NAME} ${constants_gen_depends})
321 endif (constants_gen_depends)
322 endfunction (tpqt4_constants_gen _TARGET_NAME _SPEC_XML _OUTFILE)
324 function(tpqt4_types_gen _TARGET_NAME _SPEC_XML _OUTFILE_DECL _OUTFILE_IMPL _NAMESPACE _REALINCLUDE _PRETTYINCLUDE)
325 tpqt4_extract_depends(types_gen_args types_gen_depends ${ARGN})
326 # Gather all .xml files in TelepathyQt4 and spec/ and make this target depend on those
327 file(GLOB depends_xml_files ${CMAKE_SOURCE_DIR}/TelepathyQt4/*.xml ${CMAKE_SOURCE_DIR}/spec/*.xml)
329 add_custom_command(OUTPUT ${_OUTFILE_DECL} ${_OUTFILE_IMPL}
330 COMMAND ${PYTHON_EXECUTABLE}
331 ARGS ${CMAKE_SOURCE_DIR}/tools/qt4-types-gen.py
332 --namespace=${_NAMESPACE}
333 --declfile=${_OUTFILE_DECL}
334 --implfile=${_OUTFILE_IMPL}
335 --realinclude=${_REALINCLUDE}
336 --prettyinclude=${_PRETTYINCLUDE}
338 --specxml=${_SPEC_XML}
340 DEPENDS ${CMAKE_SOURCE_DIR}/tools/libqt4codegen.py
341 ${CMAKE_SOURCE_DIR}/tools/qt4-types-gen.py
342 ${_SPEC_XML} ${depends_xml_files})
343 add_custom_target(${_TARGET_NAME} DEPENDS ${_OUTFILE_IMPL})
345 if (types_gen_depends)
346 add_dependencies(${_TARGET_NAME} ${types_gen_depends})
347 endif (types_gen_depends)
348 endfunction(tpqt4_types_gen _TARGET_NAME _SPEC_XML _OUTFILE_DECL _OUTFILE_IMPL _NAMESPACE _REALINCLUDE _PRETTYINCLUDE)
350 macro(tpqt4_add_generic_unit_test _fancyName _name)
351 tpqt4_generate_moc_i(${_name}.cpp ${CMAKE_CURRENT_BINARY_DIR}/_gen/${_name}.cpp.moc.hpp)
352 add_executable(test-${_name} ${_name}.cpp ${CMAKE_CURRENT_BINARY_DIR}/_gen/${_name}.cpp.moc.hpp)
353 target_link_libraries(test-${_name} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} telepathy-qt4 tp-qt4-tests ${ARGN})
354 add_test(${_fancyName} ${SH} ${CMAKE_CURRENT_BINARY_DIR}/runGenericTest.sh ${CMAKE_CURRENT_BINARY_DIR}/test-${_name})
355 list(APPEND _telepathy_qt4_test_cases test-${_name})
357 # Valgrind and Callgrind targets
358 _tpqt4_add_check_targets(${_fancyName} ${_name} ${CMAKE_CURRENT_BINARY_DIR}/runGenericTest.sh ${CMAKE_CURRENT_BINARY_DIR}/test-${_name})
359 endmacro(tpqt4_add_generic_unit_test _fancyName _name)
361 macro(tpqt4_add_dbus_unit_test _fancyName _name)
362 tpqt4_generate_moc_i(${_name}.cpp ${CMAKE_CURRENT_BINARY_DIR}/_gen/${_name}.cpp.moc.hpp)
363 add_executable(test-${_name} ${_name}.cpp ${CMAKE_CURRENT_BINARY_DIR}/_gen/${_name}.cpp.moc.hpp)
364 target_link_libraries(test-${_name} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} telepathy-qt4 tp-qt4-tests ${ARGN})
365 set(with_session_bus ${CMAKE_CURRENT_BINARY_DIR}/runDbusTest.sh)
366 add_test(${_fancyName} ${SH} ${with_session_bus} ${CMAKE_CURRENT_BINARY_DIR}/test-${_name})
367 list(APPEND _telepathy_qt4_test_cases test-${_name})
369 # Valgrind and Callgrind targets
370 _tpqt4_add_check_targets(${_fancyName} ${_name} ${with_session_bus} ${CMAKE_CURRENT_BINARY_DIR}/test-${_name})
371 endmacro(tpqt4_add_dbus_unit_test _fancyName _name)
373 macro(_tpqt4_add_check_targets _fancyName _name _runnerScript)
374 set_tests_properties(${_fancyName}
376 FAIL_REGULAR_EXPRESSION "^FAIL!")
378 # Standard check target
379 add_custom_target(check-${_fancyName} ${SH} ${_runnerScript} ${ARGN})
380 add_dependencies(check-${_fancyName} test-${_name})
383 add_dependencies(lcov-check test-${_name})
386 add_custom_target(check-valgrind-${_fancyName})
387 add_dependencies(check-valgrind-${_fancyName} test-${_name})
390 TARGET check-valgrind-${_fancyName}
391 COMMAND G_SLICE=always-malloc ${SH} ${_runnerScript} /usr/bin/valgrind
394 --leak-resolution=high
395 --child-silent-after-fork=yes
397 --gen-suppressions=all
398 --log-file=${CMAKE_CURRENT_BINARY_DIR}/test-${_fancyName}.memcheck.log
399 --suppressions=${CMAKE_SOURCE_DIR}/tools/tp-qt4-tests.supp
400 --suppressions=${CMAKE_SOURCE_DIR}/tools/telepathy-glib.supp
403 ${CMAKE_CURRENT_BINARY_DIR}
404 COMMENT "Running valgrind on test \"${_fancyName}\"")
405 add_dependencies(check-valgrind check-valgrind-${_fancyName})
408 add_custom_target(check-callgrind-${_fancyName})
409 add_dependencies(check-callgrind-${_fancyName} test-${_name})
411 TARGET check-callgrind-${_fancyName}
412 COMMAND ${SH} ${_runnerScript} /usr/bin/valgrind
415 --log-file=${CMAKE_CURRENT_BINARY_DIR}/test-${_fancyName}.callgrind.log
416 --callgrind-out-file=${CMAKE_CURRENT_BINARY_DIR}/test-${_fancyName}.callgrind.out
419 ${CMAKE_CURRENT_BINARY_DIR}
421 "Running callgrind on test \"${_fancyName}\"")
422 add_dependencies(check-callgrind check-callgrind-${_fancyName})
423 endmacro(_tpqt4_add_check_targets _fancyName _name)
425 function(tpqt4_setup_dbus_test_environment)
426 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/runDbusTest.sh "
428 sh ${CMAKE_SOURCE_DIR}/tools/with-session-bus.sh \\
429 --config-file=${CMAKE_BINARY_DIR}/tests/dbus-1/session.conf -- $@
431 endfunction(tpqt4_setup_dbus_test_environment)