4 # FFMPEG_FOUND, if false, do not try to link to ffmpeg
5 # FFMPEG_INCLUDE_DIR, where to find the headers
7 # $FFMPEG_DIR is an environment variable that would
8 # correspond to the ./configure --prefix=$FFMPEG_DIR
10 # Created by Robert Osfield.
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
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)
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)
24 # Macro to find header and lib directories
25 # example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
26 MACRO(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}
31 ${FFMPEG_ROOT}/include
32 $ENV{FFMPEG_DIR}/include
34 $ENV{OSG_ROOT}/include
40 /opt/local/include # DarwinPorts
41 /opt/csw/include # Blastwave
45 DOC "Location of FFMPEG Headers"
48 # newer version of ffmpeg put header in $prefix/include/[ffmpeg/]lib${shortname}
49 # so try to find lib${shortname}/header in include directory
50 IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
51 FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
52 ${FFMPEG_ROOT}/include
53 $ENV{FFMPEG_DIR}/include
55 $ENV{OSG_ROOT}/include
61 /opt/local/include # DarwinPorts
62 /opt/csw/include # Blastwave
66 DOC "Location of FFMPEG Headers"
68 ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
70 FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
88 DOC "Location of FFMPEG Libraries"
91 IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
92 SET(FFMPEG_${varname}_FOUND 1)
93 ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
97 SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
99 FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
100 FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
101 FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
102 FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
103 FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here.
105 SET(FFMPEG_FOUND "NO")
106 # Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
107 IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
109 SET(FFMPEG_FOUND "YES")
111 SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
113 SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
115 # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
117 ${FFMPEG_LIBAVFORMAT_LIBRARIES}
118 ${FFMPEG_LIBAVDEVICE_LIBRARIES}
119 ${FFMPEG_LIBAVCODEC_LIBRARIES}
120 ${FFMPEG_LIBAVUTIL_LIBRARIES})
122 ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
124 # MESSAGE(STATUS "Could not find FFMPEG")
126 ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)