~phablet-team/phablet-extras/qt-gstreamer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# - Try to find GStreamer
# Once done this will define
#
#  GSTREAMER_FOUND - system has GStreamer
#  GSTREAMER_INCLUDE_DIR - the GStreamer include directory
#  GSTREAMER_LIBRARY - the main GStreamer library
#  GSTREAMER_PLUGIN_DIR - the GStreamer plugin directory
#
#  And for all the plugin libraries specified in the COMPONENTS
#  of find_package, this module will define:
#
#  GSTREAMER_<plugin_lib>_LIBRARY_FOUND - system has <plugin_lib>
#  GSTREAMER_<plugin_lib>_LIBRARY - the <plugin_lib> library
#  GSTREAMER_<plugin_lib>_INCLUDE_DIR - the <plugin_lib> include directory
#
# Copyright (c) 2010, Collabora Ltd.
#   @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

if (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARY)
    set(GStreamer_FIND_QUIETLY TRUE)
else()
    set(GStreamer_FIND_QUIETLY FALSE)
endif()

set(GSTREAMER_ABI_VERSION "0.10")


# Find the main library
find_package(PkgConfig)

if (PKG_CONFIG_FOUND)
    pkg_check_modules(PKG_GSTREAMER gstreamer-${GSTREAMER_ABI_VERSION})
    exec_program(${PKG_CONFIG_EXECUTABLE}
                 ARGS --variable pluginsdir gstreamer-${GSTREAMER_ABI_VERSION}
                 OUTPUT_VARIABLE PKG_GSTREAMER_PLUGIN_DIR)
endif()

find_library(GSTREAMER_LIBRARY
             NAMES gstreamer-${GSTREAMER_ABI_VERSION}
             HINTS ${PKG_GSTREAMER_LIBRARY_DIRS} ${PKG_GSTREAMER_LIBDIR})

find_path(GSTREAMER_INCLUDE_DIR
          gst/gst.h
          HINTS ${PKG_GSTREAMER_INCLUDE_DIRS} ${PKG_GSTREAMER_INCLUDEDIR}
          PATH_SUFFIXES gstreamer-${GSTREAMER_ABI_VERSION})

if (PKG_GSTREAMER_PLUGIN_DIR)
    set(_GSTREAMER_PLUGIN_DIR ${PKG_GSTREAMER_PLUGIN_DIR})
else()
    get_filename_component(_GSTREAMER_LIB_DIR ${GSTREAMER_LIBRARY} PATH)
    set(_GSTREAMER_PLUGIN_DIR ${_GSTREAMER_LIB_DIR}/gstreamer-${GSTREAMER_ABI_VERSION})
endif()

set(GSTREAMER_PLUGIN_DIR ${_GSTREAMER_PLUGIN_DIR}
    CACHE PATH "The path to the gstreamer plugins installation directory")

mark_as_advanced(GSTREAMER_LIBRARY GSTREAMER_INCLUDE_DIR GSTREAMER_PLUGIN_DIR)


# Find additional libraries
include(MacroFindGStreamerLibrary)

macro(_find_gst_component _name _header)
    find_gstreamer_library(${_name} ${_header} ${GSTREAMER_ABI_VERSION})
    set(_GSTREAMER_EXTRA_VARIABLES ${_GSTREAMER_EXTRA_VARIABLES}
                                    GSTREAMER_${_name}_LIBRARY GSTREAMER_${_name}_INCLUDE_DIR)
endmacro()

foreach(_component ${GStreamer_FIND_COMPONENTS})
    if (${_component} STREQUAL "base")
        _find_gst_component(BASE gstbasesink.h)
    elseif (${_component} STREQUAL "check")
        _find_gst_component(CHECK gstcheck.h)
    elseif (${_component} STREQUAL "controller")
        _find_gst_component(CONTROLLER gstcontroller.h)
    elseif (${_component} STREQUAL "dataprotocol")
        _find_gst_component(DATAPROTOCOL dataprotocol.h)
    elseif (${_component} STREQUAL "net")
        _find_gst_component(NET gstnet.h)
    else()
        message (AUTHOR_WARNING "FindGStreamerPluginsBase.cmake: Invalid component \"${_component}\" was specified")
    endif()
endforeach()


# Version check
if (GStreamer_FIND_VERSION)
    if (PKG_GSTREAMER_FOUND)
        if("${PKG_GSTREAMER_VERSION}" VERSION_LESS "${GStreamer_FIND_VERSION}")
            message(STATUS "Found GStreamer version ${PKG_GSTREAMER_VERSION}, but at least version ${GStreamer_FIND_VERSION} is required")
            set(GSTREAMER_VERSION_COMPATIBLE FALSE)
        else()
            set(GSTREAMER_VERSION_COMPATIBLE TRUE)
        endif()
    elseif(GSTREAMER_INCLUDE_DIR)
        include(CheckCXXSourceCompiles)

        set(CMAKE_REQUIRED_INCLUDES ${GSTREAMER_INCLUDE_DIR})
        string(REPLACE "." "," _comma_version ${GStreamer_FIND_VERSION})
        # Hack to invalidate the cached value
        set(GSTREAMER_VERSION_COMPATIBLE GSTREAMER_VERSION_COMPATIBLE)

        check_cxx_source_compiles("
#define G_BEGIN_DECLS
#define G_END_DECLS
#include <gst/gstversion.h>

#if GST_CHECK_VERSION(${_comma_version})
int main() { return 0; }
#else
# error \"GStreamer version incompatible\"
#endif
" GSTREAMER_VERSION_COMPATIBLE)

        if (NOT GSTREAMER_VERSION_COMPATIBLE)
            message(STATUS "GStreamer ${GStreamer_FIND_VERSION} is required, but the version found is older")
        endif()
    else()
        # We didn't find gstreamer at all
        set(GSTREAMER_VERSION_COMPATIBLE FALSE)
    endif()
else()
    # No version constrain was specified, thus we consider the version compatible
    set(GSTREAMER_VERSION_COMPATIBLE TRUE)
endif()


include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GStreamer DEFAULT_MSG
                                  GSTREAMER_LIBRARY GSTREAMER_INCLUDE_DIR
                                  GSTREAMER_VERSION_COMPATIBLE ${_GSTREAMER_EXTRA_VARIABLES})