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

Revision 10398, 4.6 kB (checked in by robert, 5 years ago)

Fixed non windows path

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
[10395]31        ${FFMPEG_ROOT}/include/lib${shortname}
32        $ENV{FFMPEG_DIR}/include/lib${shortname}
33        ~/Library/Frameworks/lib${shortname}
34        /Library/Frameworks/lib${shortname}
35        /usr/local/include/lib${shortname}
36        /usr/include/lib${shortname}
37        /sw/include/lib${shortname} # Fink
38        /opt/local/include/lib${shortname} # DarwinPorts
39        /opt/csw/include/lib${shortname} # Blastwave
40        /opt/include/lib${shortname}
41        /usr/freeware/include/lib${shortname}
42        PATH_SUFFIXES ffmpeg
43        DOC "Location of FFMPEG Headers"
44    )
45
46    FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
47        PATHS
[9863]48        ${FFMPEG_ROOT}/include
49        $ENV{FFMPEG_DIR}/include
50        ~/Library/Frameworks
51        /Library/Frameworks
52        /usr/local/include
[9948]53        /usr/include
[9863]54        /sw/include # Fink
55        /opt/local/include # DarwinPorts
56        /opt/csw/include # Blastwave
57        /opt/include
58        /usr/freeware/include
[9948]59        PATH_SUFFIXES ffmpeg
60        DOC "Location of FFMPEG Headers"
[9863]61    )
[9817]62
[9863]63    FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
64        NAMES ${shortname}
65        PATHS
66        ${FFMPEG_ROOT}/lib
67        $ENV{FFMPEG_DIR}/lib
68        ~/Library/Frameworks
69        /Library/Frameworks
70        /usr/local/lib
71        /usr/local/lib64
72        /usr/lib
73        /usr/lib64
74        /sw/lib
75        /opt/local/lib
76        /opt/csw/lib
77        /opt/lib
78        /usr/freeware/lib64
[9948]79        DOC "Location of FFMPEG Libraries"
[9863]80    )
[9817]81
[9948]82    IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
[9863]83        SET(FFMPEG_${varname}_FOUND 1)
[9866]84    ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
[9817]85
[9863]86ENDMACRO(FFMPEG_FIND)
[9817]87
[9863]88SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
89
[10391]90# find stdint.h
[10395]91IF(WIN32)
[10391]92
[10395]93    FIND_PATH(FFMPEG_STDINT_INCLUDE_DIR stdint.h
94        PATHS
95        ${FFMPEG_ROOT}/include
96        $ENV{FFMPEG_DIR}/include
97        ~/Library/Frameworks
98        /Library/Frameworks
99        /usr/local/include
100        /usr/include
101        /sw/include # Fink
102        /opt/local/include # DarwinPorts
103        /opt/csw/include # Blastwave
104        /opt/include
105        /usr/freeware/include
106        PATH_SUFFIXES ffmpeg
107        DOC "Location of FFMPEG stdint.h Header"
108    )
109
110    IF (FFMPEG_STDINT_INCLUDE_DIR)
111        SET(STDINT_OK TRUE)
112    ENDIF()
113
114ELSE()
115
[10398]116    SET(STDINT_OK TRUE)
[10395]117
118ENDIF()
119
[9863]120FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
121FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
122FFMPEG_FIND(LIBAVCODEC  avcodec  avcodec.h)
123FFMPEG_FIND(LIBAVUTIL   avutil   avutil.h)
124FFMPEG_FIND(LIBSWSCALE  swscale  swscale.h)  # not sure about the header to look for here.
125
[9817]126SET(FFMPEG_FOUND "NO")
[9863]127# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
[10395]128IF   (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND STDINT_OK)
[9863]129
[9817]130    SET(FFMPEG_FOUND "YES")
131
132    SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
[9840]133
134    SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
135
[9863]136    # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
[9817]137    SET(FFMPEG_LIBRARIES
138        ${FFMPEG_LIBAVFORMAT_LIBRARIES}
139        ${FFMPEG_LIBAVDEVICE_LIBRARIES}
140        ${FFMPEG_LIBAVCODEC_LIBRARIES}
141        ${FFMPEG_LIBAVUTIL_LIBRARIES})
142
[10391]143ELSE ()
[9817]144
[9866]145#    MESSAGE(STATUS "Could not find FFMPEG")
[9863]146
[10391]147ENDIF()
Note: See TracBrowser for help on using the browser.