From: Colin Guthrie Date: Sun, 24 Jan 2010 11:51:57 +0000 (+0000) Subject: phonon: Allow building against kdesupport libphonon. X-Git-Tag: 1.1.0-ff~924 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=9ef1fb93b1246cd05c4b487ef255767b09e9aaa1;p=vlc phonon: Allow building against kdesupport libphonon. This uses the FindPhonon.cmake file from kdelibs to find the phonon package. Previously it would not build and gave a somewhat confusing 'Undefined Interface' error when running moc (cherry picked from commit 59ff91c95d5cb447c89bfdb8be02b518a136c7f6) Signed-off-by: Jean-Baptiste Kempf --- diff --git a/bindings/phonon/CMakeLists.txt b/bindings/phonon/CMakeLists.txt index ad5dcc76e5..a9f61a492c 100644 --- a/bindings/phonon/CMakeLists.txt +++ b/bindings/phonon/CMakeLists.txt @@ -30,6 +30,7 @@ find_package(Automoc4 REQUIRED) include (CheckCXXCompilerFlag) include (MacroEnsureVersion) +find_package(Phonon REQUIRED) find_package(VLC REQUIRED) if (NOT AUTOMOC4_VERSION) set(AUTOMOC4_VERSION "0.9.83") @@ -161,7 +162,7 @@ if(MSVC) endif(MSVC) # for including config.h and for includes like -include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/includes ${CMAKE_CURRENT_SOURCE_DIR}/phonon ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/phonon) +include_directories(${QT_INCLUDES} ${PHONON_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/includes ${CMAKE_CURRENT_SOURCE_DIR}/phonon ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/phonon) macro(_SET_FANCY _var _value _comment) if (KDESupport_SOURCE_DIR) @@ -222,7 +223,7 @@ if (CMAKE_SYSTEM_NAME MATCHES Linux) endif (CMAKE_C_COMPILER MATCHES "icc") endif (CMAKE_SYSTEM_NAME MATCHES Linux) -set(PHONON_LIBS phonon ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) +list(APPEND PHONON_LIBS phonon ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) if(QT_QTDBUS_FOUND) list(APPEND PHONON_LIBS phonon ${QT_QTDBUS_LIBRARY}) endif(QT_QTDBUS_FOUND) diff --git a/bindings/phonon/cmake/modules/FindPhonon.cmake b/bindings/phonon/cmake/modules/FindPhonon.cmake new file mode 100644 index 0000000000..daa457ad0f --- /dev/null +++ b/bindings/phonon/cmake/modules/FindPhonon.cmake @@ -0,0 +1,71 @@ +# 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) + set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/phonon/phononnamespace.h") + if (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h") + set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h") + endif (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h") + file(READ ${_phonon_namespace_header_file} _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} ${QT_LIBRARY_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)