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
41 /opt/local/include # DarwinPorts
42 /opt/csw/include # Blastwave
46 DOC "Location of FFMPEG Headers"
49 # newer version of ffmpeg put header in $prefix/include/[ffmpeg/]lib${shortname}
50 # so try to find lib${shortname}/header in include directory
51 IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
52 FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
54 ${FFMPEG_ROOT}/include
55 $ENV{FFMPEG_DIR}/include
57 $ENV{OSG_ROOT}/include
64 /opt/local/include # DarwinPorts
65 /opt/csw/include # Blastwave
69 DOC "Location of FFMPEG Headers"
71 ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
73 FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
92 DOC "Location of FFMPEG Libraries"
95 IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
96 SET(FFMPEG_${varname}_FOUND 1)
97 ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
101 SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
103 FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
104 FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
105 FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
106 FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
107 FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here.
109 SET(FFMPEG_FOUND "NO")
110 # Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
111 IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
113 SET(FFMPEG_FOUND "YES")
115 SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
117 SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
119 # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
121 ${FFMPEG_LIBAVFORMAT_LIBRARIES}
122 ${FFMPEG_LIBAVDEVICE_LIBRARIES}
123 ${FFMPEG_LIBAVCODEC_LIBRARIES}
124 ${FFMPEG_LIBAVUTIL_LIBRARIES})
126 ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
128 # MESSAGE(STATUS "Could not find FFMPEG")
130 ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)