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

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

Fixed non windows path

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
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
24# Macro to find header and lib directories
25# example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
26MACRO(FFMPEG_FIND varname shortname headername)
27    # old version of ffmpeg put header in $prefix/include/[ffmpeg]
28    # so try to find header in include directory
29    FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
30        PATHS
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
48        ${FFMPEG_ROOT}/include
49        $ENV{FFMPEG_DIR}/include
50        ~/Library/Frameworks
51        /Library/Frameworks
52        /usr/local/include
53        /usr/include
54        /sw/include # Fink
55        /opt/local/include # DarwinPorts
56        /opt/csw/include # Blastwave
57        /opt/include
58        /usr/freeware/include
59        PATH_SUFFIXES ffmpeg
60        DOC "Location of FFMPEG Headers"
61    )
62
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
79        DOC "Location of FFMPEG Libraries"
80    )
81
82    IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
83        SET(FFMPEG_${varname}_FOUND 1)
84    ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
85
86ENDMACRO(FFMPEG_FIND)
87
88SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
89
90# find stdint.h
91IF(WIN32)
92
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
116    SET(STDINT_OK TRUE)
117
118ENDIF()
119
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
126SET(FFMPEG_FOUND "NO")
127# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
128IF   (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND STDINT_OK)
129
130    SET(FFMPEG_FOUND "YES")
131
132    SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
133
134    SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
135
136    # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
137    SET(FFMPEG_LIBRARIES
138        ${FFMPEG_LIBAVFORMAT_LIBRARIES}
139        ${FFMPEG_LIBAVDEVICE_LIBRARIES}
140        ${FFMPEG_LIBAVCODEC_LIBRARIES}
141        ${FFMPEG_LIBAVUTIL_LIBRARIES})
142
143ELSE ()
144
145#    MESSAGE(STATUS "Could not find FFMPEG")
146
147ENDIF()
Note: See TracBrowser for help on using the browser.