You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.4 KiB

3 years ago
# ==============================================
# Try to find FFmpeg libraries:
# - avcodec
# - avformat
# - avdevice
# - avutil
# - swscale
# - avfilter
#
# FFMPEG_FOUND - system has FFmpeg
# FFMPEG_INCLUDE_DIR - the FFmpeg inc directory
# FFMPEG_LIBRARIES - Link these to use FFmpeg
# ==============================================
# Notice: this original script is from internet.
if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
# in cache already
set(FFMPEG_FOUND TRUE)
else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
find_path(
FFMPEG_AVCODEC_INCLUDE_DIR
NAMES libavcodec/avcodec.h
PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS}
/usr/include/ffmpeg
/usr/local/include
/usr/local/ffmpeg/include
)
find_library(
FFMPEG_LIBAVCODEC
NAMES avcodec
PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS}
/usr/lib64
/usr/local/lib
/usr/local/ffmpeg/lib
/usr/lib/aarch64-linux-gnu/
)
find_library(
FFMPEG_LIBAVFORMAT
NAMES avformat
PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS}
/usr/lib64
/usr/local/lib
/usr/local/ffmpeg/lib
/usr/lib/aarch64-linux-gnu
)
find_library(
FFMPEG_LIBSWRESAMPLE
NAMES swresample
PATHS ${_FFMPEG_SWRESAMPLE_LIBRARY_DIRS}
/usr/lib64
/usr/local/lib
/usr/local/ffmpeg/lib
/usr/lib/aarch64-linux-gnu/
)
find_library(
FFMPEG_LIBAVUTIL
NAMES avutil
PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS}
/usr/lib64
/usr/local/lib
/usr/local/ffmpeg/lib
/usr/lib/aarch64-linux-gnu/
)
find_library(
FFMPEG_LIBSWSCALE
NAMES swscale
PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS}
/usr/lib64
/usr/local/lib
/usr/local/ffmpeg/lib
/usr/lib/aarch64-linux-gnu/
)
find_library(
FFMPEG_LIBAVFILTER
NAMES avfilter
PATHS ${_FFMPEG_AVFILTER_LIBRARY_DIRS}
/usr/lib64
/usr/local/lib
/usr/local/ffmpeg/lib
/usr/lib/aarch64-linux-gnu/
)
find_library(
FFMPEG_LIBAVDEVICE
NAMES avdevice
PATHS ${_FFMPEG_AVDEVICE_LIBRARY_DIRS}
/usr/lib64
/usr/local/lib
/usr/local/ffmpeg/lib
/usr/lib/aarch64-linux-gnu/
)
if (WITH_FFMPEG_AVDEVICE AND NOT FFMPEG_LIBAVDEVICE)
message(FATAL_ERROR "Not find FFmpeg LIBAVDEVICE ")
endif ()
if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT AND FFMPEG_LIBAVUTIL AND FFMPEG_LIBSWSCALE AND FFMPEG_LIBSWRESAMPLE AND (FFMPEG_LIBAVDEVICE OR NOT WITH_FFMPEG_AVDEVICE))
set(FFMPEG_FOUND TRUE)
endif ()
if (FFMPEG_FOUND)
set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})
set(FFMPEG_LIBRARIES
${FFMPEG_LIBAVCODEC}
${FFMPEG_LIBAVFORMAT}
${FFMPEG_LIBAVUTIL}
${FFMPEG_LIBSWSCALE}
${FFMPEG_LIBSWRESAMPLE})
if (WITH_FFMPEG_AVDEVICE)
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_LIBAVDEVICE})
endif (WITH_FFMPEG_AVDEVICE)
else (FFMPEG_FOUND)
message(FATAL_ERROR "Could not find FFmpeg libraries!")
endif (FFMPEG_FOUND)
endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)