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

Revision 10226, 4.3 kB (checked in by robert, 5 years ago)

From Philip Lowman, removed inappropriate references to OSG_ in 3rd party libs searches

RevLine 
[9840]1# Locate ffmpeg
[9817]2# This module defines
3# FFMPEG_LIBRARIES
[9863]4# FFMPEG_FOUND, if false, do not try to link to ffmpeg
[9817]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#
[9863]10# Created by Robert Osfield.
[9817]11
[9948]12
13#In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>"
14#In OSG ffmpeg plugin, we use "#include <header.h>" for compatibility with old version of ffmpeg
15
16#We have to search the path which contain the header.h (usefull for old version)
17#and search the path which contain the libname/header.h (usefull for new version)
18
19#Then we need to include ${FFMPEG_libname_INCLUDE_DIRS} (in old version case, use by ffmpeg header and osg plugin code)
20#                                                       (in new version case, use by ffmpeg header)
21#and ${FFMPEG_libname_INCLUDE_DIRS/libname}             (in new version case, use by osg plugin code)
22
23
[9863]24# Macro to find header and lib directories
25# example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
26MACRO(FFMPEG_FIND varname shortname headername)
[9948]27    # old version of ffmpeg put header in $prefix/include/[ffmpeg]
28    # so try to find header in include directory
[9863]29    FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
[9948]30        PATHS
[9863]31        ${FFMPEG_ROOT}/include
32        $ENV{FFMPEG_DIR}/include
33        ~/Library/Frameworks
34        /Library/Frameworks
35        /usr/local/include
[9948]36        /usr/include
[9863]37        /sw/include # Fink
38        /opt/local/include # DarwinPorts
39        /opt/csw/include # Blastwave
40        /opt/include
41        /usr/freeware/include
[9948]42        PATH_SUFFIXES ffmpeg
43        DOC "Location of FFMPEG Headers"
[9863]44    )
[9817]45
[9948]46    # newer version of ffmpeg put header in $prefix/include/[ffmpeg/]lib${shortname}
47    # so try to find lib${shortname}/header in include directory
[9863]48    IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
49        FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
50            ${FFMPEG_ROOT}/include
51            $ENV{FFMPEG_DIR}/include
52            ~/Library/Frameworks
53            /Library/Frameworks
54            /usr/local/include
55            /usr/include/
56            /sw/include # Fink
57            /opt/local/include # DarwinPorts
58            /opt/csw/include # Blastwave
59            /opt/include
60            /usr/freeware/include
[9948]61            PATH_SUFFIXES ffmpeg
62            DOC "Location of FFMPEG Headers"
[9863]63        )
64    ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
[9817]65
[9863]66    FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
67        NAMES ${shortname}
68        PATHS
69        ${FFMPEG_ROOT}/lib
70        $ENV{FFMPEG_DIR}/lib
71        ~/Library/Frameworks
72        /Library/Frameworks
73        /usr/local/lib
74        /usr/local/lib64
75        /usr/lib
76        /usr/lib64
77        /sw/lib
78        /opt/local/lib
79        /opt/csw/lib
80        /opt/lib
81        /usr/freeware/lib64
[9948]82        DOC "Location of FFMPEG Libraries"
[9863]83    )
[9817]84
[9948]85    IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
[9863]86        SET(FFMPEG_${varname}_FOUND 1)
[9866]87    ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
[9817]88
[9863]89ENDMACRO(FFMPEG_FIND)
[9817]90
[9863]91SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
92
93FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
94FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
95FFMPEG_FIND(LIBAVCODEC  avcodec  avcodec.h)
96FFMPEG_FIND(LIBAVUTIL   avutil   avutil.h)
97FFMPEG_FIND(LIBSWSCALE  swscale  swscale.h)  # not sure about the header to look for here.
98
[9817]99SET(FFMPEG_FOUND "NO")
[9863]100# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
[9817]101IF   (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
[9863]102
[9817]103    SET(FFMPEG_FOUND "YES")
104
105    SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
[9840]106
107    SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
108
[9863]109    # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
[9817]110    SET(FFMPEG_LIBRARIES
111        ${FFMPEG_LIBAVFORMAT_LIBRARIES}
112        ${FFMPEG_LIBAVDEVICE_LIBRARIES}
113        ${FFMPEG_LIBAVCODEC_LIBRARIES}
114        ${FFMPEG_LIBAVUTIL_LIBRARIES})
115
[9863]116ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
[9817]117
[9866]118#    MESSAGE(STATUS "Could not find FFMPEG")
[9863]119
120ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
Note: See TracBrowser for help on using the browser.