| 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) |
|---|
| 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} |
|---|
| 30 | PATHS |
|---|
| 31 | ${FFMPEG_ROOT}/include |
|---|
| 32 | $ENV{FFMPEG_DIR}/include |
|---|
| 33 | ~/Library/Frameworks |
|---|
| 34 | /Library/Frameworks |
|---|
| 35 | /usr/local/include |
|---|
| 36 | /usr/include |
|---|
| 37 | /sw/include # Fink |
|---|
| 38 | /opt/local/include # DarwinPorts |
|---|
| 39 | /opt/csw/include # Blastwave |
|---|
| 40 | /opt/include |
|---|
| 41 | /usr/freeware/include |
|---|
| 42 | PATH_SUFFIXES ffmpeg |
|---|
| 43 | DOC "Location of FFMPEG Headers" |
|---|
| 44 | ) |
|---|
| 45 | |
|---|
| 46 | # newer version of ffmpeg put header in $prefix/include/[ffmpeg/]lib${shortname} |
|---|
| 47 | # so try to find lib${shortname}/header in include directory |
|---|
| 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 |
|---|
| 61 | PATH_SUFFIXES ffmpeg |
|---|
| 62 | DOC "Location of FFMPEG Headers" |
|---|
| 63 | ) |
|---|
| 64 | ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS) |
|---|
| 65 | |
|---|
| 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 |
|---|
| 82 | DOC "Location of FFMPEG Libraries" |
|---|
| 83 | ) |
|---|
| 84 | |
|---|
| 85 | IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) |
|---|
| 86 | SET(FFMPEG_${varname}_FOUND 1) |
|---|
| 87 | ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) |
|---|
| 88 | |
|---|
| 89 | ENDMACRO(FFMPEG_FIND) |
|---|
| 90 | |
|---|
| 91 | SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG") |
|---|
| 92 | |
|---|
| 93 | FFMPEG_FIND(LIBAVFORMAT avformat avformat.h) |
|---|
| 94 | FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h) |
|---|
| 95 | FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h) |
|---|
| 96 | FFMPEG_FIND(LIBAVUTIL avutil avutil.h) |
|---|
| 97 | FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here. |
|---|
| 98 | |
|---|
| 99 | SET(FFMPEG_FOUND "NO") |
|---|
| 100 | # Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional. |
|---|
| 101 | IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) |
|---|
| 102 | |
|---|
| 103 | SET(FFMPEG_FOUND "YES") |
|---|
| 104 | |
|---|
| 105 | SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}) |
|---|
| 106 | |
|---|
| 107 | SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS}) |
|---|
| 108 | |
|---|
| 109 | # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later. |
|---|
| 110 | SET(FFMPEG_LIBRARIES |
|---|
| 111 | ${FFMPEG_LIBAVFORMAT_LIBRARIES} |
|---|
| 112 | ${FFMPEG_LIBAVDEVICE_LIBRARIES} |
|---|
| 113 | ${FFMPEG_LIBAVCODEC_LIBRARIES} |
|---|
| 114 | ${FFMPEG_LIBAVUTIL_LIBRARIES}) |
|---|
| 115 | |
|---|
| 116 | ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) |
|---|
| 117 | |
|---|
| 118 | # MESSAGE(STATUS "Could not find FFMPEG") |
|---|
| 119 | |
|---|
| 120 | ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) |
|---|