| [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) |
|---|
| 26 | MACRO(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 |
|---|
| [9863] | 31 | ${FFMPEG_ROOT}/include |
|---|
| 32 | $ENV{FFMPEG_DIR}/include |
|---|
| 33 | $ENV{OSGDIR}/include |
|---|
| 34 | $ENV{OSG_ROOT}/include |
|---|
| 35 | ~/Library/Frameworks |
|---|
| 36 | /Library/Frameworks |
|---|
| 37 | /usr/local/include |
|---|
| [9948] | 38 | /usr/include |
|---|
| [9863] | 39 | /sw/include # Fink |
|---|
| 40 | /opt/local/include # DarwinPorts |
|---|
| 41 | /opt/csw/include # Blastwave |
|---|
| 42 | /opt/include |
|---|
| 43 | /usr/freeware/include |
|---|
| [9948] | 44 | PATH_SUFFIXES ffmpeg |
|---|
| 45 | DOC "Location of FFMPEG Headers" |
|---|
| [9863] | 46 | ) |
|---|
| [9817] | 47 | |
|---|
| [9948] | 48 | # newer version of ffmpeg put header in $prefix/include/[ffmpeg/]lib${shortname} |
|---|
| 49 | # so try to find lib${shortname}/header in include directory |
|---|
| [9863] | 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 |
|---|
| 54 | $ENV{OSGDIR}/include |
|---|
| 55 | $ENV{OSG_ROOT}/include |
|---|
| 56 | ~/Library/Frameworks |
|---|
| 57 | /Library/Frameworks |
|---|
| 58 | /usr/local/include |
|---|
| 59 | /usr/include/ |
|---|
| 60 | /sw/include # Fink |
|---|
| 61 | /opt/local/include # DarwinPorts |
|---|
| 62 | /opt/csw/include # Blastwave |
|---|
| 63 | /opt/include |
|---|
| 64 | /usr/freeware/include |
|---|
| [9948] | 65 | PATH_SUFFIXES ffmpeg |
|---|
| 66 | DOC "Location of FFMPEG Headers" |
|---|
| [9863] | 67 | ) |
|---|
| 68 | ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS) |
|---|
| [9817] | 69 | |
|---|
| [9863] | 70 | FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES |
|---|
| 71 | NAMES ${shortname} |
|---|
| 72 | PATHS |
|---|
| 73 | ${FFMPEG_ROOT}/lib |
|---|
| 74 | $ENV{FFMPEG_DIR}/lib |
|---|
| 75 | $ENV{OSGDIR}/lib |
|---|
| 76 | $ENV{OSG_ROOT}/lib |
|---|
| 77 | ~/Library/Frameworks |
|---|
| 78 | /Library/Frameworks |
|---|
| 79 | /usr/local/lib |
|---|
| 80 | /usr/local/lib64 |
|---|
| 81 | /usr/lib |
|---|
| 82 | /usr/lib64 |
|---|
| 83 | /sw/lib |
|---|
| 84 | /opt/local/lib |
|---|
| 85 | /opt/csw/lib |
|---|
| 86 | /opt/lib |
|---|
| 87 | /usr/freeware/lib64 |
|---|
| [9948] | 88 | DOC "Location of FFMPEG Libraries" |
|---|
| [9863] | 89 | ) |
|---|
| [9817] | 90 | |
|---|
| [9948] | 91 | IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) |
|---|
| [9863] | 92 | SET(FFMPEG_${varname}_FOUND 1) |
|---|
| [9866] | 93 | ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) |
|---|
| [9817] | 94 | |
|---|
| [9863] | 95 | ENDMACRO(FFMPEG_FIND) |
|---|
| [9817] | 96 | |
|---|
| [9863] | 97 | SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG") |
|---|
| 98 | |
|---|
| 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. |
|---|
| 104 | |
|---|
| [9817] | 105 | SET(FFMPEG_FOUND "NO") |
|---|
| [9863] | 106 | # Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional. |
|---|
| [9817] | 107 | IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) |
|---|
| [9863] | 108 | |
|---|
| [9817] | 109 | SET(FFMPEG_FOUND "YES") |
|---|
| 110 | |
|---|
| 111 | SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}) |
|---|
| [9840] | 112 | |
|---|
| 113 | SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS}) |
|---|
| 114 | |
|---|
| [9863] | 115 | # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later. |
|---|
| [9817] | 116 | SET(FFMPEG_LIBRARIES |
|---|
| 117 | ${FFMPEG_LIBAVFORMAT_LIBRARIES} |
|---|
| 118 | ${FFMPEG_LIBAVDEVICE_LIBRARIES} |
|---|
| 119 | ${FFMPEG_LIBAVCODEC_LIBRARIES} |
|---|
| 120 | ${FFMPEG_LIBAVUTIL_LIBRARIES}) |
|---|
| 121 | |
|---|
| [9863] | 122 | ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) |
|---|
| [9817] | 123 | |
|---|
| [9866] | 124 | # MESSAGE(STATUS "Could not find FFMPEG") |
|---|
| [9863] | 125 | |
|---|
| 126 | ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) |
|---|