Commit b7e64126 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf
Browse files

Phonon Backend using VLC

This still uses CMake, because I am still lazy.
This has been tested on Linux, but I would like to port it to win32 (and so CMake might not be the best)
This is basically a copy of the KDE-playground code and started as the GSoC of last summer
parent 4d748cb8
.svn
Makefile
CMakeTmp
# - Try to find automoc4
# Once done this will define
#
# AUTOMOC4_FOUND - automoc4 has been found
# AUTOMOC4_EXECUTABLE - the automoc4 tool
# AUTOMOC4_VERSION - the full version of automoc4
# AUTOMOC4_VERSION_MAJOR, AUTOMOC4_VERSION_MINOR, AUTOMOC4_VERSION_PATCH - AUTOMOC4_VERSION
# broken into its components
#
# It also adds the following macros
# AUTOMOC4(<target> <SRCS_VAR>)
# Use this to run automoc4 on all files contained in the list <SRCS_VAR>.
#
# AUTOMOC4_MOC_HEADERS(<target> header1.h header2.h ...)
# Use this to add more header files to be processed with automoc4.
#
# AUTOMOC4_ADD_EXECUTABLE(<target_NAME> src1 src2 ...)
# This macro does the same as ADD_EXECUTABLE, but additionally
# adds automoc4 handling for all source files.
#
# AUTOMOC4_ADD_LIBRARY(<target_NAME> src1 src2 ...)
# This macro does the same as ADD_LIBRARY, but additionally
# adds automoc4 handling for all source files.
# Internal helper macro, may change or be removed anytime:
# _ADD_AUTOMOC4_TARGET(<target_NAME> <SRCS_VAR>)
#
# Since version 0.9.88:
# The following two macros are only to be used for KDE4 projects
# and do something which makes sure automoc4 works for KDE. Don't
# use them anywhere else.
# _AUTOMOC4_KDE4_PRE_TARGET_HANDLING(<target_NAME> <SRCS_VAR>)
# _AUTOMOC4_KDE4_POST_TARGET_HANDLING(<target_NAME>)
# Copyright (c) 2008-2009, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# check if we are inside KDESupport and automoc is enabled
if("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
# when building this project as part of kdesupport
set(AUTOMOC4_CONFIG_FILE "${KDESupport_SOURCE_DIR}/automoc/Automoc4Config.cmake")
else("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
# when building this project outside kdesupport
# CMAKE_[SYSTEM_]PREFIX_PATH exists starting with cmake 2.6.0
file(TO_CMAKE_PATH "$ENV{CMAKE_PREFIX_PATH}" _env_CMAKE_PREFIX_PATH)
file(TO_CMAKE_PATH "$ENV{CMAKE_LIBRARY_PATH}" _env_CMAKE_LIBRARY_PATH)
find_file(AUTOMOC4_CONFIG_FILE NAMES Automoc4Config.cmake
PATH_SUFFIXES automoc4 lib/automoc4 lib64/automoc4
PATHS ${_env_CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ${CMAKE_SYSTEM_PREFIX_PATH}
${_env_CMAKE_LIBRARY_PATH} ${CMAKE_LIBRARY_PATH} ${CMAKE_SYSTEM_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}
NO_DEFAULT_PATH )
endif("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
if(AUTOMOC4_CONFIG_FILE)
include(${AUTOMOC4_CONFIG_FILE})
set(AUTOMOC4_FOUND TRUE)
else(AUTOMOC4_CONFIG_FILE)
set(AUTOMOC4_FOUND FALSE)
endif(AUTOMOC4_CONFIG_FILE)
if (AUTOMOC4_FOUND)
if (NOT Automoc4_FIND_QUIETLY)
message(STATUS "Found Automoc4: ${AUTOMOC4_EXECUTABLE}")
endif (NOT Automoc4_FIND_QUIETLY)
else (AUTOMOC4_FOUND)
if (Automoc4_FIND_REQUIRED)
message(FATAL_ERROR "Did not find automoc4 (part of kdesupport).")
else (Automoc4_FIND_REQUIRED)
if (NOT Automoc4_FIND_QUIETLY)
message(STATUS "Did not find automoc4 (part of kdesupport).")
endif (NOT Automoc4_FIND_QUIETLY)
endif (Automoc4_FIND_REQUIRED)
endif (AUTOMOC4_FOUND)
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... )
#
# This macro is intended to be used in FindXXX.cmake modules files.
# It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and
# it also sets the <UPPERCASED_NAME>_FOUND variable.
# The package is found if all variables listed are TRUE.
# Example:
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
#
# LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
# If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
# independent whether QUIET was used or not.
#
# If it is found, the location is reported using the VAR1 argument, so
# here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out.
# If the second argument is DEFAULT_MSG, the message in the failure case will
# be "Could NOT find LibXml2", if you don't like this message you can specify
# your own custom failure message there.
MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 )
IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
IF (${_NAME}_FIND_REQUIRED)
SET(_FAIL_MESSAGE "Could not find REQUIRED package ${_NAME}")
ELSE (${_NAME}_FIND_REQUIRED)
SET(_FAIL_MESSAGE "Could not find OPTIONAL package ${_NAME}")
ENDIF (${_NAME}_FIND_REQUIRED)
ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
SET(_FAIL_MESSAGE "${_FAIL_MSG}")
ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
STRING(TOUPPER ${_NAME} _NAME_UPPER)
SET(${_NAME_UPPER}_FOUND TRUE)
IF(NOT ${_VAR1})
SET(${_NAME_UPPER}_FOUND FALSE)
ENDIF(NOT ${_VAR1})
FOREACH(_CURRENT_VAR ${ARGN})
IF(NOT ${_CURRENT_VAR})
SET(${_NAME_UPPER}_FOUND FALSE)
ENDIF(NOT ${_CURRENT_VAR})
ENDFOREACH(_CURRENT_VAR)
IF (${_NAME_UPPER}_FOUND)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ELSE (${_NAME_UPPER}_FOUND)
IF (${_NAME}_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}")
ELSE (${_NAME}_FIND_REQUIRED)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "${_FAIL_MESSAGE}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ENDIF (${_NAME}_FIND_REQUIRED)
ENDIF (${_NAME_UPPER}_FOUND)
ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
# - Try to find VLC library
# Once done this will define
#
# VLC_FOUND - system has VLC
# VLC_INCLUDE_DIR - The VLC include directory
# VLC_LIBRARIES - The libraries needed to use VLC
# VLC_DEFINITIONS - Compiler switches required for using VLC
#
# Copyright (C) 2008, Tanguy Krotoff <tkrotoff@gmail.com>
# Copyright (C) 2008, Lukas Durfina <lukas.durfina@gmail.com>
# Copyright (c) 2009, Fathi Boudra <fboudra@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if(VLC_INCLUDE_DIR AND VLC_LIBRARIES)
# in cache already
set(VLC_FIND_QUIETLY TRUE)
endif(VLC_INCLUDE_DIR AND VLC_LIBRARIES)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if(NOT WIN32)
find_package(PkgConfig)
pkg_check_modules(VLC libvlc>=1.0.0)
set(VLC_DEFINITIONS ${VLC_CFLAGS})
endif(NOT WIN32)
# TODO add argument support to pass version on find_package
include(MacroEnsureVersion)
macro_ensure_version(1.0.0 ${VLC_VERSION} VLC_VERSION_OK)
if(VLC_VERSION_OK)
set(VLC_FOUND TRUE)
message(STATUS "VLC library found")
else(VLC_VERSION_OK)
set(VLC_FOUND FALSE)
message(FATAL_ERROR "VLC library not found")
endif(VLC_VERSION_OK)
find_path(VLC_INCLUDE_DIR
NAMES vlc.h
PATHS ${VLC_INCLUDE_DIRS}
PATH_SUFFIXES vlc)
find_library(VLC_LIBRARIES
NAMES vlc
PATHS ${VLC_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VLC DEFAULT_MSG VLC_INCLUDE_DIR VLC_LIBRARIES)
# show the VLC_INCLUDE_DIR and VLC_LIBRARIES variables only in the advanced view
mark_as_advanced(VLC_INCLUDE_DIR VLC_LIBRARIES)
# This file defines the following macros for developers to use in ensuring
# that installed software is of the right version:
#
# MACRO_ENSURE_VERSION - test that a version number is greater than
# or equal to some minimum
# MACRO_ENSURE_VERSION_RANGE - test that a version number is greater than
# or equal to some minimum and less than some
# maximum
# MACRO_ENSURE_VERSION2 - deprecated, do not use in new code
#
# MACRO_ENSURE_VERSION
# This macro compares version numbers of the form "x.y.z" or "x.y"
# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK)
# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION
# Leading and trailing text is ok, e.g.
# MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK)
# which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system
# Copyright (c) 2006, David Faure, <faure@kde.org>
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# MACRO_ENSURE_VERSION_RANGE
# This macro ensures that a version number of the form
# "x.y.z" or "x.y" falls within a range defined by
# min_version <= found_version < max_version.
# If this expression holds, FOO_VERSION_OK will be set TRUE
#
# Example: MACRO_ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK )
#
# This macro will break silently if any of x,y,z are greater than 100.
#
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# NORMALIZE_VERSION
# Helper macro to convert version numbers of the form "x.y.z"
# to an integer equal to 10^4 * x + 10^2 * y + z
#
# This macro will break silently if any of x,y,z are greater than 100.
#
# Copyright (c) 2006, David Faure, <faure@kde.org>
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# CHECK_RANGE_INCLUSIVE_LOWER
# Helper macro to check whether x <= y < z
#
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO(NORMALIZE_VERSION _requested_version _normalized_version)
STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}")
if (_threePartMatch)
# parse the parts of the version string
STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}")
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}")
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}")
else (_threePartMatch)
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}")
STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}")
set(_patch_vers "0")
endif (_threePartMatch)
# compute an overall version number which can be compared at once
MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}")
ENDMACRO(NORMALIZE_VERSION)
MACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok)
if (${_value} LESS ${_lower_limit})
set( ${_ok} FALSE )
elseif (${_value} EQUAL ${_lower_limit})
set( ${_ok} TRUE )
elseif (${_value} EQUAL ${_upper_limit})
set( ${_ok} FALSE )
elseif (${_value} GREATER ${_upper_limit})
set( ${_ok} FALSE )
else (${_value} LESS ${_lower_limit})
set( ${_ok} TRUE )
endif (${_value} LESS ${_lower_limit})
ENDMACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER)
MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old)
NORMALIZE_VERSION( ${requested_version} req_vers_num )
NORMALIZE_VERSION( ${found_version} found_vers_num )
if (found_vers_num LESS req_vers_num)
set( ${var_too_old} FALSE )
else (found_vers_num LESS req_vers_num)
set( ${var_too_old} TRUE )
endif (found_vers_num LESS req_vers_num)
ENDMACRO(MACRO_ENSURE_VERSION)
MACRO(MACRO_ENSURE_VERSION2 requested_version2 found_version2 var_too_old2)
MACRO_ENSURE_VERSION( ${requested_version2} ${found_version2} ${var_too_old2})
ENDMACRO(MACRO_ENSURE_VERSION2)
MACRO(MACRO_ENSURE_VERSION_RANGE min_version found_version max_version var_ok)
NORMALIZE_VERSION( ${min_version} req_vers_num )
NORMALIZE_VERSION( ${found_version} found_vers_num )
NORMALIZE_VERSION( ${max_version} max_vers_num )
MACRO_CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok})
ENDMACRO(MACRO_ENSURE_VERSION_RANGE)
# This file defines the Feature Logging macros.
#
# MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]])
# Logs the information so that it can be displayed at the end
# of the configure run
# VAR : TRUE or FALSE, indicating whether the feature is supported
# FEATURE: name of the feature, e.g. "libjpeg"
# DESCRIPTION: description what this feature provides
# URL: home page
# REQUIRED: TRUE or FALSE, indicating whether the featue is required
# MIN_VERSION: minimum version number. empty string if unneeded
# COMMENTS: More info you may want to provide. empty string if unnecessary
#
# MACRO_DISPLAY_FEATURE_LOG()
# Call this to display the collected results.
# Exits CMake with a FATAL error message if a required feature is missing
#
# Example:
#
# INCLUDE(MacroLogFeature)
#
# FIND_PACKAGE(JPEG)
# MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "")
# ...
# MACRO_DISPLAY_FEATURE_LOG()
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2006, Allen Winter, <winter@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (NOT _macroLogFeatureAlreadyIncluded)
SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
IF (EXISTS ${_file})
FILE(REMOVE ${_file})
ENDIF (EXISTS ${_file})
SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
IF (EXISTS ${_file})
FILE(REMOVE ${_file})
ENDIF (EXISTS ${_file})
SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
IF (EXISTS ${_file})
FILE(REMOVE ${_file})
ENDIF (EXISTS ${_file})
SET(_macroLogFeatureAlreadyIncluded TRUE)
ENDIF (NOT _macroLogFeatureAlreadyIncluded)
MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments)
SET(_required "${ARGV4}")
SET(_minvers "${ARGV5}")
SET(_comments "${ARGV6}")
IF (${_var})
SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
ELSE (${_var})
IF (${_required} MATCHES "[Tt][Rr][Uu][Ee]")
SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
ELSE (${_required} MATCHES "[Tt][Rr][Uu][Ee]")
SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
ENDIF (${_required} MATCHES "[Tt][Rr][Uu][Ee]")
ENDIF (${_var})
SET(_logtext "+ ${_package}")
IF (NOT ${_var})
IF (${_minvers} MATCHES ".*")
SET(_logtext "${_logtext}, ${_minvers}")
ENDIF (${_minvers} MATCHES ".*")
SET(_logtext "${_logtext}: ${_description} <${_url}>")
IF (${_comments} MATCHES ".*")
SET(_logtext "${_logtext}\n${_comments}")
ENDIF (${_comments} MATCHES ".*")
# SET(_logtext "${_logtext}\n") #double-space missing features?
ENDIF (NOT ${_var})
FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n")
ENDMACRO(MACRO_LOG_FEATURE)
MACRO(MACRO_DISPLAY_FEATURE_LOG)
SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
IF (EXISTS ${_file})
FILE(READ ${_file} _requirements)
MESSAGE(STATUS "\n-----------------------------------------------------------------------------\n-- The following REQUIRED packages could NOT be located on your system.\n-- Please install them before continuing this software installation.\n-----------------------------------------------------------------------------\n${_requirements}-----------------------------------------------------------------------------")
FILE(REMOVE ${_file})
MESSAGE(FATAL_ERROR "Exiting: Missing Requirements")
ENDIF (EXISTS ${_file})
SET(_summary "\n")
SET(_elist 0)
SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
IF (EXISTS ${_file})
SET(_elist 1)
FILE(READ ${_file} _enabled)
FILE(REMOVE ${_file})
SET(_summary "${_summary}-----------------------------------------------------------------------------\n-- The following external packages were located on your system.\n-- This installation will have the extra features provided by these packages.\n${_enabled}")
ENDIF (EXISTS ${_file})
SET(_dlist 0)
SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
IF (EXISTS ${_file})
SET(_dlist 1)
FILE(READ ${_file} _disabled)
FILE(REMOVE ${_file})
SET(_summary "${_summary}-----------------------------------------------------------------------------\n-- The following OPTIONAL packages could NOT be located on your system.\n-- Consider installing them to enable more features from this software.\n${_disabled}")
ELSE (EXISTS ${_file})
IF (${_elist})
SET(_summary "${_summary}Congratulations! All external packages have been found.\n")
ENDIF (${_elist})
ENDIF (EXISTS ${_file})
IF (${_elist} OR ${_dlist})
SET(_summary "${_summary}-----------------------------------------------------------------------------\n")
ENDIF (${_elist} OR ${_dlist})
MESSAGE(STATUS "${_summary}")
ENDMACRO(MACRO_DISPLAY_FEATURE_LOG)
# - MACRO_OPTIONAL_FIND_PACKAGE() combines FIND_PACKAGE() with an OPTION()
# MACRO_OPTIONAL_FIND_PACKAGE( <name> [QUIT] )
# This macro is a combination of OPTION() and FIND_PACKAGE(), it
# works like FIND_PACKAGE(), but additionally it automatically creates
# an option name WITH_<name>, which can be disabled via the cmake GUI.
# or via -DWITH_<name>=OFF
# The standard <name>_FOUND variables can be used in the same way
# as when using the normal FIND_PACKAGE()
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO (MACRO_OPTIONAL_FIND_PACKAGE _name )
OPTION(WITH_${_name} "Search for ${_name} package" ON)
if (WITH_${_name})
FIND_PACKAGE(${_name} ${ARGN})
else (WITH_${_name})
set(${_name}_FOUND)
set(${_name}_INCLUDE_DIR)
set(${_name}_INCLUDES)
set(${_name}_LIBRARY)
set(${_name}_LIBRARIES)
endif (WITH_${_name})
ENDMACRO (MACRO_OPTIONAL_FIND_PACKAGE)
# Phonon helper macros:
#
# macro (phonon_add_executable _target)
# macro (PHONON_ADD_UNIT_TEST _test_NAME)
# macro (PHONON_UPDATE_ICONCACHE)
# macro (PHONON_UPDATE_ICONCACHE)
# macro (_PHONON_ADD_ICON_INSTALL_RULE _install_SCRIPT _install_PATH _group _orig_NAME _install_NAME _l10n_SUBDIR)
# macro (PHONON_INSTALL_ICONS _defaultpath )
set(_global_add_executable_param)
if (Q_WS_MAC)
set(_global_add_executable_param MACOSX_BUNDLE)
endif (Q_WS_MAC)
if (WIN32)
# no WIN32 here - all executables are command line executables
set(_global_add_executable_param)
endif (WIN32)
macro(phonon_add_executable _target)
set(_srcs ${ARGN})
automoc4_add_executable(${_target} ${_global_add_executable_param} ${_srcs})
endmacro(phonon_add_executable _target)
macro (PHONON_ADD_UNIT_TEST _test_NAME)
set(_srcList ${ARGN})
set(_nogui)
list(GET ${_srcList} 0 first_PARAM)
set(_add_executable_param ${_global_add_executable_param})
if(${first_PARAM} STREQUAL "NOGUI")
set(_nogui "NOGUI")
set(_add_executable_param)
endif(${first_PARAM} STREQUAL "NOGUI")
if (NOT PHONON_BUILD_TESTS)
set(_add_executable_param ${_add_executable_param} EXCLUDE_FROM_ALL)
endif (NOT PHONON_BUILD_TESTS)
automoc4_add_executable(${_test_NAME} ${_add_executable_param} ${_srcList})
if(NOT PHONON_TEST_OUTPUT)
set(PHONON_TEST_OUTPUT plaintext)
endif(NOT PHONON_TEST_OUTPUT)
set(PHONON_TEST_OUTPUT ${PHONON_TEST_OUTPUT} CACHE STRING "The output to generate when running the QTest unit tests")
set(using_qtest "")
foreach(_filename ${_srcList})
if(NOT using_qtest)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_filename}")
file(READ ${_filename} file_CONTENT)
string(REGEX MATCH "QTEST_(KDE)?MAIN" using_qtest "${file_CONTENT}")
endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_filename}")
endif(NOT using_qtest)
endforeach(_filename)
set(_executable ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME})
if (Q_WS_MAC AND NOT _nogui)
set(_executable ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME}.app/Contents/MacOS/${_test_NAME})
else (Q_WS_MAC AND NOT _nogui)
# Use .shell wrapper where available, to use uninstalled libs.
#if (UNIX)
# set(_executable ${_executable}.shell)
#endif (UNIX)
endif (Q_WS_MAC AND NOT _nogui)
if (using_qtest AND PHONON_TEST_OUTPUT STREQUAL "xml")
add_test( ${_test_NAME} ${_executable} -xml -o ${_test_NAME}.tml)
else (using_qtest AND PHONON_TEST_OUTPUT STREQUAL "xml")
add_test( ${_test_NAME} ${_executable} )
endif (using_qtest AND PHONON_TEST_OUTPUT STREQUAL "xml")
if (NOT MSVC_IDE) #not needed for the ide
# if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests
if (NOT PHONON_BUILD_TESTS)
get_directory_property(_buildtestsAdded BUILDTESTS_ADDED)
if(NOT _buildtestsAdded)
add_custom_target(buildtests)
set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE)
endif(NOT _buildtestsAdded)
add_dependencies(buildtests ${_test_NAME})
endif (NOT PHONON_BUILD_TESTS)
endif (NOT MSVC_IDE)
endmacro (PHONON_ADD_UNIT_TEST)
macro (PHONON_UPDATE_ICONCACHE)
# Update mtime of hicolor icon theme dir.
# We don't always have touch command (e.g. on Windows), so instead create
# and delete a temporary file in the theme dir.
install(CODE "
set(DESTDIR_VALUE \"\$ENV{DESTDIR}\")
if (NOT DESTDIR_VALUE)
file(WRITE \"${ICON_INSTALL_DIR}/hicolor/temp.txt\" \"update\")
file(REMOVE \"${ICON_INSTALL_DIR}/hicolor/temp.txt\")
endif (NOT DESTDIR_VALUE)
")
endmacro (PHONON_UPDATE_ICONCACHE)
# a "map" of short type names to the directories
# unknown names should give empty results
# KDE 3 compatibility
set(_PHONON_ICON_GROUP_mime "mimetypes")
set(_PHONON_ICON_GROUP_filesys "places")
set(_PHONON_ICON_GROUP_device "devices")
set(_PHONON_ICON_GROUP_app "apps")
set(_PHONON_ICON_GROUP_action "actions")
# KDE 4 / icon naming specification compatibility
set(_PHONON_ICON_GROUP_mimetypes "mimetypes")
set(_PHONON_ICON_GROUP_places "places")
set(_PHONON_ICON_GROUP_devices "devices")
set(_PHONON_ICON_GROUP_apps "apps")
set(_PHONON_ICON_GROUP_actions "actions")
set(_PHONON_ICON_GROUP_categories "categories")
set(_PHONON_ICON_GROUP_status "status")