[GTK][WPE] Enable X-Content-Type-Options: nosniff
[WebKit.git] / Source / cmake / FindGStreamer.cmake
1 # - Try to find GStreamer and its plugins
2 # Once done, this will define
3 #
4 #  GSTREAMER_FOUND - system has GStreamer
5 #  GSTREAMER_INCLUDE_DIRS - the GStreamer include directories
6 #  GSTREAMER_LIBRARIES - link these to use GStreamer
7 #
8 # Additionally, gstreamer-base is always looked for and required, and
9 # the following related variables are defined:
10 #
11 #  GSTREAMER_BASE_INCLUDE_DIRS - gstreamer-base's include directory
12 #  GSTREAMER_BASE_LIBRARIES - link to these to use gstreamer-base
13 #
14 # Optionally, the COMPONENTS keyword can be passed to find_package()
15 # and GStreamer plugins can be looked for.  Currently, the following
16 # plugins can be searched, and they define the following variables if
17 # found:
18 #
19 #  gstreamer-app:        GSTREAMER_APP_INCLUDE_DIRS and GSTREAMER_APP_LIBRARIES
20 #  gstreamer-audio:      GSTREAMER_AUDIO_INCLUDE_DIRS and GSTREAMER_AUDIO_LIBRARIES
21 #  gstreamer-fft:        GSTREAMER_FFT_INCLUDE_DIRS and GSTREAMER_FFT_LIBRARIES
22 #  gstreamer-gl:         GSTREAMER_GL_INCLUDE_DIRS and GSTREAMER_GL_LIBRARIES
23 #  gstreamer-mpegts:     GSTREAMER_MPEGTS_INCLUDE_DIRS and GSTREAMER_MPEGTS_LIBRARIES
24 #  gstreamer-pbutils:    GSTREAMER_PBUTILS_INCLUDE_DIRS and GSTREAMER_PBUTILS_LIBRARIES
25 #  gstreamer-tag:        GSTREAMER_TAG_INCLUDE_DIRS and GSTREAMER_TAG_LIBRARIES
26 #  gstreamer-video:      GSTREAMER_VIDEO_INCLUDE_DIRS and GSTREAMER_VIDEO_LIBRARIES
27 #
28 # Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
29 #
30 # Redistribution and use in source and binary forms, with or without
31 # modification, are permitted provided that the following conditions
32 # are met:
33 # 1.  Redistributions of source code must retain the above copyright
34 #     notice, this list of conditions and the following disclaimer.
35 # 2.  Redistributions in binary form must reproduce the above copyright
36 #     notice, this list of conditions and the following disclaimer in the
37 #     documentation and/or other materials provided with the distribution.
38 #
39 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
40 # IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
41 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
43 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
45 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
46 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
48 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
49 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50
51 find_package(PkgConfig)
52
53 # Helper macro to find a GStreamer plugin (or GStreamer itself)
54 #   _component_prefix is prepended to the _INCLUDE_DIRS and _LIBRARIES variables (eg. "GSTREAMER_AUDIO")
55 #   _pkgconfig_name is the component's pkg-config name (eg. "gstreamer-1.0", or "gstreamer-video-1.0").
56 #   _library is the component's library name (eg. "gstreamer-1.0" or "gstvideo-1.0")
57 macro(FIND_GSTREAMER_COMPONENT _component_prefix _pkgconfig_name _library)
58
59     string(REGEX MATCH "(.*)>=(.*)" _dummy "${_pkgconfig_name}")
60     if ("${CMAKE_MATCH_2}" STREQUAL "")
61         pkg_check_modules(PC_${_component_prefix} "${_pkgconfig_name} >= ${GStreamer_FIND_VERSION}")
62     else ()
63         pkg_check_modules(PC_${_component_prefix} ${_pkgconfig_name})
64     endif ()
65     set(${_component_prefix}_INCLUDE_DIRS ${PC_${_component_prefix}_INCLUDE_DIRS})
66
67     find_library(${_component_prefix}_LIBRARIES
68         NAMES ${_library}
69         HINTS ${PC_${_component_prefix}_LIBRARY_DIRS} ${PC_${_component_prefix}_LIBDIR}
70     )
71 endmacro()
72
73 # ------------------------
74 # 1. Find GStreamer itself
75 # ------------------------
76
77 # 1.1. Find headers and libraries
78 FIND_GSTREAMER_COMPONENT(GSTREAMER gstreamer-1.0 gstreamer-1.0)
79 FIND_GSTREAMER_COMPONENT(GSTREAMER_BASE gstreamer-base-1.0 gstbase-1.0)
80
81 # -------------------------
82 # 2. Find GStreamer plugins
83 # -------------------------
84
85 FIND_GSTREAMER_COMPONENT(GSTREAMER_APP gstreamer-app-1.0 gstapp-1.0)
86 FIND_GSTREAMER_COMPONENT(GSTREAMER_AUDIO gstreamer-audio-1.0 gstaudio-1.0)
87 FIND_GSTREAMER_COMPONENT(GSTREAMER_FFT gstreamer-fft-1.0 gstfft-1.0)
88 FIND_GSTREAMER_COMPONENT(GSTREAMER_GL gstreamer-gl-1.0 gstgl-1.0)
89 FIND_GSTREAMER_COMPONENT(GSTREAMER_MPEGTS gstreamer-mpegts-1.0>=1.4.0 gstmpegts-1.0)
90 FIND_GSTREAMER_COMPONENT(GSTREAMER_PBUTILS gstreamer-pbutils-1.0 gstpbutils-1.0)
91 FIND_GSTREAMER_COMPONENT(GSTREAMER_TAG gstreamer-tag-1.0 gsttag-1.0)
92 FIND_GSTREAMER_COMPONENT(GSTREAMER_VIDEO gstreamer-video-1.0 gstvideo-1.0)
93
94 # ------------------------------------------------
95 # 3. Process the COMPONENTS passed to FIND_PACKAGE
96 # ------------------------------------------------
97 set(_GSTREAMER_REQUIRED_VARS GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES GSTREAMER_VERSION GSTREAMER_BASE_INCLUDE_DIRS GSTREAMER_BASE_LIBRARIES)
98
99 foreach (_component ${GStreamer_FIND_COMPONENTS})
100     set(_gst_component "GSTREAMER_${_component}")
101     string(TOUPPER ${_gst_component} _UPPER_NAME)
102
103     list(APPEND _GSTREAMER_REQUIRED_VARS ${_UPPER_NAME}_INCLUDE_DIRS ${_UPPER_NAME}_LIBRARIES)
104 endforeach ()
105
106 include(FindPackageHandleStandardArgs)
107 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GStreamer REQUIRED_VARS _GSTREAMER_REQUIRED_VARS
108                                             VERSION_VAR   GSTREAMER_VERSION)
109
110 mark_as_advanced(
111     GSTREAMER_APP_INCLUDE_DIRS
112     GSTREAMER_APP_LIBRARIES
113     GSTREAMER_AUDIO_INCLUDE_DIRS
114     GSTREAMER_AUDIO_LIBRARIES
115     GSTREAMER_BASE_INCLUDE_DIRS
116     GSTREAMER_BASE_LIBRARIES
117     GSTREAMER_FFT_INCLUDE_DIRS
118     GSTREAMER_FFT_LIBRARIES
119     GSTREAMER_GL_INCLUDE_DIRS
120     GSTREAMER_GL_LIBRARIES
121     GSTREAMER_INCLUDE_DIRS
122     GSTREAMER_LIBRARIES
123     GSTREAMER_MPEGTS_INCLUDE_DIRS
124     GSTREAMER_MPEGTS_LIBRARIES
125     GSTREAMER_PBUTILS_INCLUDE_DIRS
126     GSTREAMER_PBUTILS_LIBRARIES
127     GSTREAMER_TAG_INCLUDE_DIRS
128     GSTREAMER_TAG_LIBRARIES
129     GSTREAMER_VIDEO_INCLUDE_DIRS
130     GSTREAMER_VIDEO_LIBRARIES
131 )