2009-03-03 18:53:26 +08:00
|
|
|
# Locate ffmpeg
|
2009-02-26 00:05:12 +08:00
|
|
|
# This module defines
|
|
|
|
# FFMPEG_LIBRARIES
|
2009-03-05 00:16:07 +08:00
|
|
|
# FFMPEG_FOUND, if false, do not try to link to ffmpeg
|
2009-02-26 00:05:12 +08:00
|
|
|
# FFMPEG_INCLUDE_DIR, where to find the headers
|
|
|
|
#
|
|
|
|
# $FFMPEG_DIR is an environment variable that would
|
|
|
|
# correspond to the ./configure --prefix=$FFMPEG_DIR
|
|
|
|
#
|
2009-03-05 00:16:07 +08:00
|
|
|
# Created by Robert Osfield.
|
2009-02-26 00:05:12 +08:00
|
|
|
|
2009-03-23 23:48:19 +08:00
|
|
|
|
|
|
|
#In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>"
|
2013-02-06 20:46:03 +08:00
|
|
|
#In OSG ffmpeg plugin, we used "#include <header.h>" for compatibility with old version of ffmpeg
|
|
|
|
#With the new version of FFmpeg, a file named "time.h" was added that breaks compatability with the old version of ffmpeg.
|
2009-03-23 23:48:19 +08:00
|
|
|
|
2015-04-13 18:43:56 +08:00
|
|
|
#We have to search the path which contain the header.h (useful for old version)
|
|
|
|
#and search the path which contain the libname/header.h (useful for new version)
|
2009-03-23 23:48:19 +08:00
|
|
|
|
|
|
|
#Then we need to include ${FFMPEG_libname_INCLUDE_DIRS} (in old version case, use by ffmpeg header and osg plugin code)
|
|
|
|
# (in new version case, use by ffmpeg header)
|
|
|
|
#and ${FFMPEG_libname_INCLUDE_DIRS/libname} (in new version case, use by osg plugin code)
|
|
|
|
|
|
|
|
|
2009-03-05 00:16:07 +08:00
|
|
|
# Macro to find header and lib directories
|
|
|
|
# example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
|
|
|
|
MACRO(FFMPEG_FIND varname shortname headername)
|
2009-03-23 23:48:19 +08:00
|
|
|
# old version of ffmpeg put header in $prefix/include/[ffmpeg]
|
|
|
|
# so try to find header in include directory
|
2009-06-26 00:02:23 +08:00
|
|
|
|
|
|
|
FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
|
2009-06-24 18:26:48 +08:00
|
|
|
PATHS
|
2009-06-26 00:02:23 +08:00
|
|
|
${FFMPEG_ROOT}/include
|
|
|
|
$ENV{FFMPEG_DIR}/include
|
2014-12-18 03:20:48 +08:00
|
|
|
${FFMPEG_ROOT}
|
|
|
|
$ENV{FFMPEG_DIR}
|
2009-06-26 00:02:23 +08:00
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/usr/local/include
|
|
|
|
/usr/include
|
|
|
|
/sw/include # Fink
|
|
|
|
/opt/local/include # DarwinPorts
|
|
|
|
/opt/csw/include # Blastwave
|
|
|
|
/opt/include
|
|
|
|
/usr/freeware/include
|
2009-06-24 18:26:48 +08:00
|
|
|
PATH_SUFFIXES ffmpeg
|
|
|
|
DOC "Location of FFMPEG Headers"
|
|
|
|
)
|
|
|
|
|
2009-03-05 00:16:07 +08:00
|
|
|
FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
|
2009-03-23 23:48:19 +08:00
|
|
|
PATHS
|
2009-03-05 00:16:07 +08:00
|
|
|
${FFMPEG_ROOT}/include
|
|
|
|
$ENV{FFMPEG_DIR}/include
|
2014-12-18 03:20:48 +08:00
|
|
|
${FFMPEG_ROOT}
|
|
|
|
$ENV{FFMPEG_DIR}
|
2009-03-05 00:16:07 +08:00
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/usr/local/include
|
2009-03-23 23:48:19 +08:00
|
|
|
/usr/include
|
2009-03-05 00:16:07 +08:00
|
|
|
/sw/include # Fink
|
|
|
|
/opt/local/include # DarwinPorts
|
|
|
|
/opt/csw/include # Blastwave
|
|
|
|
/opt/include
|
|
|
|
/usr/freeware/include
|
2009-03-23 23:48:19 +08:00
|
|
|
PATH_SUFFIXES ffmpeg
|
|
|
|
DOC "Location of FFMPEG Headers"
|
2009-03-05 00:16:07 +08:00
|
|
|
)
|
2009-02-26 00:05:12 +08:00
|
|
|
|
2009-03-05 00:16:07 +08:00
|
|
|
FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
|
|
|
|
NAMES ${shortname}
|
|
|
|
PATHS
|
|
|
|
${FFMPEG_ROOT}/lib
|
|
|
|
$ENV{FFMPEG_DIR}/lib
|
2014-12-18 03:20:48 +08:00
|
|
|
${FFMPEG_ROOT}/lib${shortname}
|
|
|
|
$ENV{FFMPEG_DIR}/lib${shortname}
|
2009-03-05 00:16:07 +08:00
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/usr/local/lib
|
|
|
|
/usr/local/lib64
|
|
|
|
/usr/lib
|
|
|
|
/usr/lib64
|
|
|
|
/sw/lib
|
|
|
|
/opt/local/lib
|
|
|
|
/opt/csw/lib
|
|
|
|
/opt/lib
|
|
|
|
/usr/freeware/lib64
|
2009-03-23 23:48:19 +08:00
|
|
|
DOC "Location of FFMPEG Libraries"
|
2009-03-05 00:16:07 +08:00
|
|
|
)
|
2009-02-26 00:05:12 +08:00
|
|
|
|
2009-03-23 23:48:19 +08:00
|
|
|
IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
|
2009-03-05 00:16:07 +08:00
|
|
|
SET(FFMPEG_${varname}_FOUND 1)
|
2009-03-05 22:33:21 +08:00
|
|
|
ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
|
2009-02-26 00:05:12 +08:00
|
|
|
|
2009-03-05 00:16:07 +08:00
|
|
|
ENDMACRO(FFMPEG_FIND)
|
|
|
|
|
|
|
|
SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
|
|
|
|
|
2009-06-23 18:53:55 +08:00
|
|
|
# find stdint.h
|
2009-06-24 18:26:48 +08:00
|
|
|
IF(WIN32)
|
|
|
|
|
|
|
|
FIND_PATH(FFMPEG_STDINT_INCLUDE_DIR stdint.h
|
|
|
|
PATHS
|
|
|
|
${FFMPEG_ROOT}/include
|
|
|
|
$ENV{FFMPEG_DIR}/include
|
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/usr/local/include
|
|
|
|
/usr/include
|
|
|
|
/sw/include # Fink
|
|
|
|
/opt/local/include # DarwinPorts
|
|
|
|
/opt/csw/include # Blastwave
|
|
|
|
/opt/include
|
|
|
|
/usr/freeware/include
|
|
|
|
PATH_SUFFIXES ffmpeg
|
|
|
|
DOC "Location of FFMPEG stdint.h Header"
|
|
|
|
)
|
|
|
|
|
|
|
|
IF (FFMPEG_STDINT_INCLUDE_DIR)
|
|
|
|
SET(STDINT_OK TRUE)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
|
2009-06-25 00:45:55 +08:00
|
|
|
SET(STDINT_OK TRUE)
|
2009-06-24 18:26:48 +08:00
|
|
|
|
|
|
|
ENDIF()
|
2009-06-23 18:53:55 +08:00
|
|
|
|
2009-03-05 00:16:07 +08:00
|
|
|
FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
|
|
|
|
FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
|
|
|
|
FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
|
|
|
|
FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
|
2015-01-07 22:14:55 +08:00
|
|
|
FFMPEG_FIND(LIBSWRESAMPLE swresample swresample.h)
|
|
|
|
FFMPEG_FIND(LIBAVRESAMPLE avresample avresample.h)
|
2009-03-05 00:16:07 +08:00
|
|
|
FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here.
|
2009-02-26 00:05:12 +08:00
|
|
|
|
|
|
|
SET(FFMPEG_FOUND "NO")
|
2009-03-05 00:16:07 +08:00
|
|
|
# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
|
2015-01-07 22:14:55 +08:00
|
|
|
IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND STDINT_OK
|
|
|
|
AND ( FFMPEG_LIBSWRESAMPLE_FOUND OR FFMPEG_LIBAVRESAMPLE_FOUND ) )
|
2009-03-05 00:16:07 +08:00
|
|
|
|
2009-02-26 00:05:12 +08:00
|
|
|
SET(FFMPEG_FOUND "YES")
|
|
|
|
|
2010-02-22 18:10:08 +08:00
|
|
|
SET(FFMPEG_INCLUDE_DIRS
|
2013-02-06 20:46:03 +08:00
|
|
|
${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
|
|
|
|
${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}
|
|
|
|
${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
|
|
|
|
${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
|
2009-06-26 00:02:23 +08:00
|
|
|
)
|
|
|
|
|
2013-02-06 20:46:03 +08:00
|
|
|
# Using the new include style for FFmpeg prevents issues with #include <time.h>
|
2010-05-27 22:35:10 +08:00
|
|
|
IF (FFMPEG_STDINT_INCLUDE_DIR)
|
2009-06-26 00:02:23 +08:00
|
|
|
SET(FFMPEG_INCLUDE_DIRS
|
2010-02-22 18:10:08 +08:00
|
|
|
${FFMPEG_INCLUDE_DIRS}
|
|
|
|
${FFMPEG_STDINT_INCLUDE_DIR}
|
2009-06-26 00:02:23 +08:00
|
|
|
)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
2009-03-03 18:53:26 +08:00
|
|
|
SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
|
|
|
|
|
2009-03-05 00:16:07 +08:00
|
|
|
# Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
|
2009-02-26 00:05:12 +08:00
|
|
|
SET(FFMPEG_LIBRARIES
|
|
|
|
${FFMPEG_LIBAVFORMAT_LIBRARIES}
|
|
|
|
${FFMPEG_LIBAVDEVICE_LIBRARIES}
|
|
|
|
${FFMPEG_LIBAVCODEC_LIBRARIES}
|
|
|
|
${FFMPEG_LIBAVUTIL_LIBRARIES})
|
|
|
|
|
2009-06-23 18:53:55 +08:00
|
|
|
ELSE ()
|
2009-03-05 00:16:07 +08:00
|
|
|
|
2009-03-05 22:33:21 +08:00
|
|
|
# MESSAGE(STATUS "Could not find FFMPEG")
|
2009-02-26 00:05:12 +08:00
|
|
|
|
2009-06-23 18:53:55 +08:00
|
|
|
ENDIF()
|