1 # - Try to find GStreamer and its plugins
2 # Once done, this will define
4 # GSTREAMER_FOUND - system has GStreamer
5 # GSTREAMER_INCLUDE_DIRS - the GStreamer include directories
6 # GSTREAMER_LIBRARIES - link these to use GStreamer
8 # Additionally, gstreamer-base is always looked for and required, and
9 # the following related variables are defined:
11 # GSTREAMER_BASE_INCLUDE_DIRS - gstreamer-base's include directory
12 # GSTREAMER_BASE_LIBRARIES - link to these to use gstreamer-base
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
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-interfaces: GSTREAMER_INTERFACES_INCLUDE_DIRS and GSTREAMER_INTERFACES_LIBRARIES
23 # gstreamer-pbutils: GSTREAMER_PBUTILS_INCLUDE_DIRS and GSTREAMER_PBUTILS_LIBRARIES
24 # gstreamer-video: GSTREAMER_VIDEO_INCLUDE_DIRS and GSTREAMER_VIDEO_LIBRARIES
26 # Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
28 # Redistribution and use in source and binary forms, with or without
29 # modification, are permitted provided that the following conditions
31 # 1. Redistributions of source code must retain the above copyright
32 # notice, this list of conditions and the following disclaimer.
33 # 2. Redistributions in binary form must reproduce the above copyright
34 # notice, this list of conditions and the following disclaimer in the
35 # documentation and/or other materials provided with the distribution.
37 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
38 # IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
39 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
41 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
42 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
43 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
44 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
45 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
46 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 FIND_PACKAGE(PkgConfig)
51 # The minimum GStreamer version we support.
52 SET(GSTREAMER_MINIMUM_VERSION 0.10.30)
54 # Helper macro to find a GStreamer plugin (or GStreamer itself)
55 # _component_prefix is prepended to the _INCLUDE_DIRS and _LIBRARIES variables (eg. "GSTREAMER_AUDIO")
56 # _pkgconfig_name is the component's pkg-config name (eg. "gstreamer-0.10", or "gstreamer-video-0.10").
57 # _header is the component's header, relative to the gstreamer-0.10 directory (eg. "gst/gst.h").
58 # _library is the component's library name (eg. "gstreamer-0.10" or "gstvideo-0.10")
59 MACRO(FIND_GSTREAMER_COMPONENT _component_prefix _pkgconfig_name _header _library)
60 # FIXME: The QUIET keyword can be used once we require CMake 2.8.2.
61 PKG_CHECK_MODULES(PC_${_component_prefix} ${_pkgconfig_name})
63 FIND_PATH(${_component_prefix}_INCLUDE_DIRS
65 HINTS ${PC_${_component_prefix}_INCLUDE_DIRS} ${PC_${_component_prefix}_INCLUDEDIR}
66 PATH_SUFFIXES gstreamer-0.10
69 FIND_LIBRARY(${_component_prefix}_LIBRARIES
71 HINTS ${PC_${_component_prefix}_LIBRARY_DIRS} ${PC_${_component_prefix}_LIBDIR}
75 # ------------------------
76 # 1. Find GStreamer itself
77 # ------------------------
79 # 1.1. Find headers and libraries
80 FIND_GSTREAMER_COMPONENT(GSTREAMER gstreamer-0.10 gst/gst.h gstreamer-0.10)
81 FIND_GSTREAMER_COMPONENT(GSTREAMER_BASE gstreamer-base-0.10 gst/gst.h gstbase-0.10)
83 # 1.2. Check GStreamer version
84 IF (GSTREAMER_INCLUDE_DIRS)
85 IF (EXISTS "${GSTREAMER_INCLUDE_DIRS}/gst/gstversion.h")
86 FILE (READ "${GSTREAMER_INCLUDE_DIRS}/gst/gstversion.h" GSTREAMER_VERSION_CONTENTS)
88 STRING(REGEX MATCH "#define +GST_VERSION_MAJOR +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
89 SET(GSTREAMER_VERSION_MAJOR "${CMAKE_MATCH_1}")
91 STRING(REGEX MATCH "#define +GST_VERSION_MINOR +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
92 SET(GSTREAMER_VERSION_MINOR "${CMAKE_MATCH_1}")
94 STRING(REGEX MATCH "#define +GST_VERSION_MICRO +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
95 SET(GSTREAMER_VERSION_MICRO "${CMAKE_MATCH_1}")
97 SET(GSTREAMER_VERSION "${GSTREAMER_VERSION_MAJOR}.${GSTREAMER_VERSION_MINOR}.${GSTREAMER_VERSION_MICRO}")
101 # FIXME: With CMake 2.8.3 we can just pass GSTREAMER_VERSION to FIND_PACKAGE_HANDLE_STARNDARD_ARGS as VERSION_VAR
102 # and remove the version check here (GSTREAMER_MINIMUM_VERSION would be passed to FIND_PACKAGE).
104 IF ("${GSTREAMER_VERSION}" VERSION_LESS "${GSTREAMER_MINIMUM_VERSION}")
105 SET(VERSION_OK FALSE)
108 # -------------------------
109 # 2. Find GStreamer plugins
110 # -------------------------
112 FIND_GSTREAMER_COMPONENT(GSTREAMER_APP gstreamer-app-0.10 gst/app/gstappsink.h gstapp-0.10)
113 FIND_GSTREAMER_COMPONENT(GSTREAMER_AUDIO gstreamer-audio-0.10 gst/audio/audio.h gstaudio-0.10)
114 FIND_GSTREAMER_COMPONENT(GSTREAMER_FFT gstreamer-fft-0.10 gst/fft/gstfft.h gstfft-0.10)
115 FIND_GSTREAMER_COMPONENT(GSTREAMER_INTERFACES gstreamer-interfaces-0.10 gst/interfaces/mixer.h gstinterfaces-0.10)
116 FIND_GSTREAMER_COMPONENT(GSTREAMER_PBUTILS gstreamer-pbutils-0.10 gst/pbutils/pbutils.h gstpbutils-0.10)
117 FIND_GSTREAMER_COMPONENT(GSTREAMER_VIDEO gstreamer-video-0.10 gst/video/video.h gstvideo-0.10)
119 # ------------------------------------------------
120 # 3. Process the COMPONENTS passed to FIND_PACKAGE
121 # ------------------------------------------------
122 SET(_GSTREAMER_REQUIRED_VARS GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES VERSION_OK GSTREAMER_BASE_INCLUDE_DIRS GSTREAMER_BASE_LIBRARIES)
124 FOREACH(_component ${GStreamer_FIND_COMPONENTS})
125 SET(_gst_component "GSTREAMER_${_component}")
126 STRING(TOUPPER ${_gst_component} _UPPER_NAME)
128 LIST(APPEND _GSTREAMER_REQUIRED_VARS ${_UPPER_NAME}_INCLUDE_DIRS ${_UPPER_NAME}_LIBRARIES)
131 INCLUDE(FindPackageHandleStandardArgs)
132 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GStreamer DEFAULT_MSG ${_GSTREAMER_REQUIRED_VARS})