root/OpenSceneGraph/trunk/CMakeModules/FindFFmpeg.cmake @ 9863

Revision 9863, 3.5 kB (checked in by robert, 6 years ago)

From Jean-Sebastien Guay, added non pkg-config based ffmpeg search scheme.

Line 
1# Locate ffmpeg
2# This module defines
3# FFMPEG_LIBRARIES
4# FFMPEG_FOUND, if false, do not try to link to ffmpeg
5# FFMPEG_INCLUDE_DIR, where to find the headers
6#
7# $FFMPEG_DIR is an environment variable that would
8# correspond to the ./configure --prefix=$FFMPEG_DIR
9#
10# Created by Robert Osfield.
11
12# Macro to find header and lib directories
13# example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
14MACRO(FFMPEG_FIND varname shortname headername)
15    # First try to find header directly in include directory
16    FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
17        ${FFMPEG_ROOT}/include
18        $ENV{FFMPEG_DIR}/include
19        $ENV{OSGDIR}/include
20        $ENV{OSG_ROOT}/include
21        ~/Library/Frameworks
22        /Library/Frameworks
23        /usr/local/include
24        /usr/include/
25        /sw/include # Fink
26        /opt/local/include # DarwinPorts
27        /opt/csw/include # Blastwave
28        /opt/include
29        /usr/freeware/include
30    )
31
32    # If not found, try to find it in a subdirectory. Tanguy's build has
33    # avformat.h in include/libavformat, so this catches that case. If that's
34    # standard, perhaps we can keep just this case.
35    IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
36        FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
37            ${FFMPEG_ROOT}/include
38            $ENV{FFMPEG_DIR}/include
39            $ENV{OSGDIR}/include
40            $ENV{OSG_ROOT}/include
41            ~/Library/Frameworks
42            /Library/Frameworks
43            /usr/local/include
44            /usr/include/
45            /sw/include # Fink
46            /opt/local/include # DarwinPorts
47            /opt/csw/include # Blastwave
48            /opt/include
49            /usr/freeware/include
50        )
51    ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
52
53    FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
54        NAMES ${shortname}
55        PATHS
56        ${FFMPEG_ROOT}/lib
57        $ENV{FFMPEG_DIR}/lib
58        $ENV{OSGDIR}/lib
59        $ENV{OSG_ROOT}/lib
60        ~/Library/Frameworks
61        /Library/Frameworks
62        /usr/local/lib
63        /usr/local/lib64
64        /usr/lib
65        /usr/lib64
66        /sw/lib
67        /opt/local/lib
68        /opt/csw/lib
69        /opt/lib
70        /usr/freeware/lib64
71    )
72
73    IF   (FFMPEG_${varname}_LIBRARIES)
74        SET(FFMPEG_${varname}_FOUND 1)
75    ENDIF(FFMPEG_${varname}_LIBRARIES)
76
77ENDMACRO(FFMPEG_FIND)
78
79SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
80
81FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
82FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
83FFMPEG_FIND(LIBAVCODEC  avcodec  avcodec.h)
84FFMPEG_FIND(LIBAVUTIL   avutil   avutil.h)
85FFMPEG_FIND(LIBSWSCALE  swscale  swscale.h)  # not sure about the header to look for here.
86
87SET(FFMPEG_FOUND "NO")
88# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
89IF   (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
90
91    SET(FFMPEG_FOUND "YES")
92
93    SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
94
95    SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
96
97    # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
98    SET(FFMPEG_LIBRARIES
99        ${FFMPEG_LIBAVFORMAT_LIBRARIES}
100        ${FFMPEG_LIBAVDEVICE_LIBRARIES}
101        ${FFMPEG_LIBAVCODEC_LIBRARIES}
102        ${FFMPEG_LIBAVUTIL_LIBRARIES})
103
104ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
105
106    MESSAGE(STATUS "Could not find FFMPEG")
107
108ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
Note: See TracBrowser for help on using the browser.