Improve the build system; add new features and examples:
[qtgstreamer:qtgstreamer.git] / cmake / modules / FindGStreamer.cmake
1 # - Try to find GStreamer
2 # Once done this will define
3 #
4 #  GSTREAMER_FOUND - system has GStreamer
5 #  GSTREAMER_INCLUDE_DIR - the GStreamer include directory
6 #  GSTREAMER_LIBRARIES - the libraries needed to use GStreamer
7 #  GSTREAMER_DEFINITIONS - Compiler switches required for using GStreamer
8
9 # Copyright (c) 2006, Tim Beaulen <tbscope@gmail.com>
10 #
11 # Redistribution and use is allowed according to the terms of the BSD license.
12 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
13
14 # TODO: Other versions --> GSTREAMER_X_Y_FOUND (Example: GSTREAMER_0_8_FOUND and GSTREAMER_0_10_FOUND etc)
15
16 IF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_INTERFACE_LIBRARY)
17    # in cache already
18    SET(GStreamer_FIND_QUIETLY TRUE)
19 ELSE (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_INTERFACE_LIBRARY)
20    SET(GStreamer_FIND_QUIETLY FALSE)
21 ENDIF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_INTERFACE_LIBRARY)
22
23 IF (NOT WIN32)
24    # use pkg-config to get the directories and then use these values
25    # in the FIND_PATH() and FIND_LIBRARY() calls
26    FIND_PACKAGE(PkgConfig)
27    PKG_CHECK_MODULES(PC_GSTREAMER gstreamer-0.10)
28    #MESSAGE(STATUS "DEBUG: GStreamer include directory = ${GSTREAMER_INCLUDE_DIRS}")
29    #MESSAGE(STATUS "DEBUG: GStreamer link directory = ${GSTREAMER_LIBRARY_DIRS}")
30    #MESSAGE(STATUS "DEBUG: GStreamer CFlags = ${GSTREAMER_CFLAGS_OTHER}") 
31    SET(GSTREAMER_DEFINITIONS ${PC_GSTREAMER_CFLAGS_OTHER})
32 ENDIF (NOT WIN32)
33
34 FIND_PATH(GSTREAMER_INCLUDE_DIR gst/gst.h
35    PATHS
36    ${PC_GSTREAMER_INCLUDEDIR}
37    ${PC_GSTREAMER_INCLUDE_DIRS}
38    #PATH_SUFFIXES gst
39    )
40
41 FIND_LIBRARY(GSTREAMER_LIBRARIES NAMES gstreamer-0.10
42    PATHS
43    ${PC_GSTREAMER_LIBDIR}
44    ${PC_GSTREAMER_LIBRARY_DIRS}
45    )
46
47 FIND_LIBRARY(GSTREAMER_BASE_LIBRARY NAMES gstbase-0.10
48    PATHS
49    ${PC_GSTREAMER_LIBDIR}
50    ${PC_GSTREAMER_LIBRARY_DIRS}
51    )
52
53 FIND_LIBRARY(GSTREAMER_INTERFACE_LIBRARY NAMES gstinterfaces-0.10
54    PATHS
55    ${PC_GSTREAMER_LIBDIR}
56    ${PC_GSTREAMER_LIBRARY_DIRS}
57    )
58
59 IF (GSTREAMER_INCLUDE_DIR)
60    #MESSAGE(STATUS "DEBUG: Found GStreamer include dir: ${GSTREAMER_INCLUDE_DIR}")
61 ELSE (GSTREAMER_INCLUDE_DIR)
62    MESSAGE(STATUS "GStreamer: WARNING: include dir not found")
63 ENDIF (GSTREAMER_INCLUDE_DIR)
64
65 IF (GSTREAMER_LIBRARIES)
66    #MESSAGE(STATUS "DEBUG: Found GStreamer library: ${GSTREAMER_LIBRARIES}")
67 ELSE (GSTREAMER_LIBRARIES)
68    MESSAGE(STATUS "GStreamer: WARNING: library not found")
69 ENDIF (GSTREAMER_LIBRARIES)
70
71 IF (GSTREAMER_INTERFACE_LIBRARY)
72    #MESSAGE(STATUS "DEBUG: Found GStreamer interface library: ${GSTREAMER_INTERFACE_LIBRARY}")
73 ELSE (GSTREAMER_INTERFACE_LIBRARY)
74    MESSAGE(STATUS "GStreamer: WARNING: interface library not found")
75 ENDIF (GSTREAMER_INTERFACE_LIBRARY)
76
77 INCLUDE(FindPackageHandleStandardArgs)
78 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GStreamer  DEFAULT_MSG  GSTREAMER_LIBRARIES GSTREAMER_INCLUDE_DIR GSTREAMER_BASE_LIBRARY GSTREAMER_INTERFACE_LIBRARY)
79
80 MARK_AS_ADVANCED(GSTREAMER_INCLUDE_DIR GSTREAMER_LIBRARIES GSTREAMER_BASE_LIBRARY GSTREAMER_INTERFACE_LIBRARY)