Updated French translation (#4946)
[opentx.git] / cmake / FindPhonon.cmake
blob23ec18dfc1086d7941d6876fdd8cb9c0efa30511
1 # Find libphonon
2 # Once done this will define
4 #  PHONON_FOUND    - system has Phonon Library
5 #  PHONON_INCLUDES - the Phonon include directory
6 #  PHONON_LIBS     - link these to use Phonon
7 #  PHONON_VERSION  - the version of the Phonon Library
9 # Copyright (c) 2008, Matthias Kretz <kretz@kde.org>
11 # Redistribution and use is allowed according to the terms of the BSD license.
12 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 macro(_phonon_find_version)
15    set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/phonon/phononnamespace.h")
16    if (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h")
17       set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h")
18    endif (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h")
19    file(READ ${_phonon_namespace_header_file} _phonon_header LIMIT 5000 OFFSET 1000)
20    string(REGEX MATCH "define PHONON_VERSION_STR \"(4\\.[0-9]+\\.[0-9a-z]+)\"" _phonon_version_match "${_phonon_header}")
21    set(PHONON_VERSION "${CMAKE_MATCH_1}")
22    message(STATUS "Phonon Version: ${PHONON_VERSION}")
23 endmacro(_phonon_find_version)
25 if(PHONON_FOUND)
26    # Already found, nothing more to do except figuring out the version
27    _phonon_find_version()
28 else(PHONON_FOUND)
29    if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
30       set(PHONON_FIND_QUIETLY TRUE)
31    endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
33    # As discussed on kde-buildsystem: first look at CMAKE_PREFIX_PATH, then at the suggested PATHS (kde4 install dir)
34    find_library(PHONON_LIBRARY NAMES phonon phonon4 PATHS ${KDE4_LIB_INSTALL_DIR} ${QT_LIBRARY_DIR} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
35    # then at the default system locations (CMAKE_SYSTEM_PREFIX_PATH, i.e. /usr etc.)
36    find_library(PHONON_LIBRARY NAMES phonon)
38    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)
39    find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h)
41    if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
42       set(PHONON_LIBS ${phonon_LIB_DEPENDS} ${PHONON_LIBRARY})
43       set(PHONON_INCLUDES ${PHONON_INCLUDE_DIR}/KDE ${PHONON_INCLUDE_DIR})
44       set(PHONON_FOUND TRUE)
45       _phonon_find_version()
46    else(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
47       set(PHONON_FOUND FALSE)
48    endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
50    if(PHONON_FOUND)
51       if(NOT PHONON_FIND_QUIETLY)
52          message(STATUS "Found Phonon: ${PHONON_LIBRARY}")
53          message(STATUS "Found Phonon Includes: ${PHONON_INCLUDES}")
54       endif(NOT PHONON_FIND_QUIETLY)
55    else(PHONON_FOUND)
56       if(Phonon_FIND_REQUIRED)
57          if(NOT PHONON_INCLUDE_DIR)
58             message(STATUS "Phonon includes NOT found!")
59          endif(NOT PHONON_INCLUDE_DIR)
60          if(NOT PHONON_LIBRARY)
61             message(STATUS "Phonon library NOT found!")
62          endif(NOT PHONON_LIBRARY)
63          message(FATAL_ERROR "Phonon library or includes NOT found!")
64       else(Phonon_FIND_REQUIRED)
65          message(STATUS "Unable to find Phonon")
66       endif(Phonon_FIND_REQUIRED)
67    endif(PHONON_FOUND)
70    mark_as_advanced(PHONON_INCLUDE_DIR PHONON_LIBRARY PHONON_INCLUDES)
71 endif(PHONON_FOUND)