From: Manuel Nickschas Date: Thu, 18 Dec 2008 20:00:11 +0000 (+0100) Subject: Enable Phonon support in our build system X-Git-Tag: 0.4.0~366 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=603f1fd2e9501d84a320554f068df26861ebde71 Enable Phonon support in our build system FindPhonon.cmake shamelessly stolen from KDE. Should also work with qt-phonon, though I couldn't test that. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 36922f86..2a7d0fc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,9 @@ # -DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF) # : select binaries to build # -DWITH_OPENSSL=OFF : Disable OpenSSL support -# -DWITH_DBUS=OFF : Disable D-Bus support -# -DWITH_WEBKIT=OFF : Disable WebKit support +# -DWITH_DBUS=OFF : Disable D-Bus support (dbus notifications) +# -DWITH_WEBKIT=OFF : Disable WebKit support (link previews) +# -DWITH_PHONON=OFF : Disable Phonon support (audio notifications) # -DOXYGEN_ICONS=(Builtin|External) : If "Builtin" (the default), compile our Oxygen Icon Theme subset into the binary # : If "External", we assume Oxygen is already installed on the system # -DQUASSEL_ICONS=(Builtin|External) : If "Builtin" (the default), put our own icons into the binary @@ -34,7 +35,8 @@ option(WANT_MONO "Build the monolithic (all-in-one) binary" ON) option(WITH_OPENSSL "Enable OpenSSL support if present on the system" ON) option(WITH_DBUS "Enable D-Bus support if present on the system" ON) -option(WITH_WEBKIT "Enable WebKit support if present on the system" ON) +option(WITH_WEBKIT "Enable WebKit support (for link previews)" ON) +option(WITH_PHONON "Enable Phonon support (for audio notifications)" ON) option(STATIC "Enable static building (might not be portable)" OFF) option(DEPLOY "Mac OS X only! Adds required libs to bundle resources and create a dmg. Note: requires Qt to be built with 10.4u SDK" OFF) @@ -150,6 +152,20 @@ else(WITH_WEBKIT) message(STATUS "Disabling WebKit support") endif(WITH_WEBKIT) +# Setup Phonon support +if(WITH_PHONON) + find_package(Phonon) + if(PHONON_FOUND) + message(STATUS "Enabling Phonon support") + add_definitions(-DHAVE_PHONON) + set(HAVE_PHONON true) + set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_PHONON) + else(PHONON_FOUND) + message(STATUS "Phonon not found, disabling audio notifications") + endif(PHONON_FOUND) +else(WITH_PHONON) + message(STATUS "Disabling Phonon support") +endif(WITH_PHONON) # Set global buildflags # This is very much non-portable, so don't use -DSTATIC until you know what diff --git a/cmake/modules/FindPhonon.cmake b/cmake/modules/FindPhonon.cmake new file mode 100644 index 00000000..93332697 --- /dev/null +++ b/cmake/modules/FindPhonon.cmake @@ -0,0 +1,67 @@ +# Find libphonon +# Once done this will define +# +# PHONON_FOUND - system has Phonon Library +# PHONON_INCLUDES - the Phonon include directory +# PHONON_LIBS - link these to use Phonon +# PHONON_VERSION - the version of the Phonon Library + +# Copyright (c) 2008, Matthias Kretz +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +macro(_phonon_find_version) + file(READ "${PHONON_INCLUDE_DIR}/phonon/phononnamespace.h" _phonon_header LIMIT 5000 OFFSET 1000) + string(REGEX MATCH "define PHONON_VERSION_STR \"(4\\.[0-9]+\\.[0-9a-z]+)\"" _phonon_version_match "${_phonon_header}") + set(PHONON_VERSION "${CMAKE_MATCH_1}") + message(STATUS "Phonon Version: ${PHONON_VERSION}") +endmacro(_phonon_find_version) + +if(PHONON_FOUND) + # Already found, nothing more to do except figuring out the version + _phonon_find_version() +else(PHONON_FOUND) + if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY) + set(PHONON_FIND_QUIETLY TRUE) + endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY) + + # As discussed on kde-buildsystem: first look at CMAKE_PREFIX_PATH, then at the suggested PATHS (kde4 install dir) + find_library(PHONON_LIBRARY NAMES phonon PATHS ${KDE4_LIB_INSTALL_DIR} ${QT_LIBRARY_DIR} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + # then at the default system locations (CMAKE_SYSTEM_PREFIX_PATH, i.e. /usr etc.) + find_library(PHONON_LIBRARY NAMES phonon) + + find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h PATHS ${KDE4_INCLUDE_INSTALL_DIR} ${QT_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h) + + if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY) + set(PHONON_LIBS ${phonon_LIB_DEPENDS} ${PHONON_LIBRARY}) + set(PHONON_INCLUDES ${PHONON_INCLUDE_DIR}/KDE ${PHONON_INCLUDE_DIR}) + set(PHONON_FOUND TRUE) + _phonon_find_version() + else(PHONON_INCLUDE_DIR AND PHONON_LIBRARY) + set(PHONON_FOUND FALSE) + endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY) + + if(PHONON_FOUND) + if(NOT PHONON_FIND_QUIETLY) + message(STATUS "Found Phonon: ${PHONON_LIBRARY}") + message(STATUS "Found Phonon Includes: ${PHONON_INCLUDES}") + endif(NOT PHONON_FIND_QUIETLY) + else(PHONON_FOUND) + if(Phonon_FIND_REQUIRED) + if(NOT PHONON_INCLUDE_DIR) + message(STATUS "Phonon includes NOT found!") + endif(NOT PHONON_INCLUDE_DIR) + if(NOT PHONON_LIBRARY) + message(STATUS "Phonon library NOT found!") + endif(NOT PHONON_LIBRARY) + message(FATAL_ERROR "Phonon library or includes NOT found!") + else(Phonon_FIND_REQUIRED) + message(STATUS "Unable to find Phonon") + endif(Phonon_FIND_REQUIRED) + endif(PHONON_FOUND) + + + mark_as_advanced(PHONON_INCLUDE_DIR PHONON_LIBRARY PHONON_INCLUDES) +endif(PHONON_FOUND) diff --git a/cmake/modules/README b/cmake/modules/README index fa122a85..2b41b903 100644 --- a/cmake/modules/README +++ b/cmake/modules/README @@ -1,4 +1,4 @@ -These modules have been copied from KDE's repository as of 2008-06-17. +Most of these modules have been copied from KDE's repository. FindQt4 has been adjusted to still contain the library deps and Qt config stuff from the original FindQt4 (of cmake 2.4.7). Also, I've fixed OpenSSL diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da979d59..a599e9d9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,7 +50,7 @@ if(WANT_QTCLIENT) COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DBUILD_QTUI" OUTPUT_NAME ../quasselclient) target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common - ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES}) + ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES} ${PHONON_LIBS}) install(TARGETS quasselclient RUNTIME DESTINATION ${BIN_INSTALL_DIR}) endif(WANT_QTCLIENT) @@ -63,7 +63,7 @@ if(WANT_MONO) COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO" OUTPUT_NAME ../quassel) target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common - ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES}) + ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES} ${PHONON_LIBS}) install(TARGETS quassel RUNTIME DESTINATION ${BIN_INSTALL_DIR}) endif(WANT_MONO) diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 1cc2f283..9ff3bf4e 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -121,6 +121,13 @@ IF(HAVE_DBUS) qt4_add_dbus_interface(DBUS ../../interfaces/org.freedesktop.Notifications.xml desktopnotificationinterface) ENDIF(HAVE_DBUS) +IF(HAVE_PHONON) + set(SOURCES ${SOURCES} ) + set(MOC_HDRS ${MOC_HDRS} ) + set(FORMS ${FORMS} ) + include_directories(${PHONON_INCLUDES}) +ENDIF(HAVE_PHONON) + foreach(FORM ${FORMS}) set(FORMPATH ${FORMPATH} ui/${FORM}) endforeach(FORM ${FORMS})