2017-09-13 13:09:40 +02:00
|
|
|
# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil)
|
|
|
|
# Once done this will define
|
|
|
|
#
|
|
|
|
# FFMPEG_FOUND - system has ffmpeg or libav
|
|
|
|
# FFMPEG_INCLUDE_DIR - the ffmpeg include directory
|
|
|
|
# FFMPEG_LIBRARIES - Link these to use ffmpeg
|
|
|
|
# FFMPEG_LIBAVCODEC
|
|
|
|
# FFMPEG_LIBAVFORMAT
|
|
|
|
# FFMPEG_LIBAVUTIL
|
|
|
|
#
|
|
|
|
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
|
|
|
|
# Modified for other libraries by Lasse Kärkkäinen <tronic>
|
|
|
|
# Modified for Hedgewars by Stepik777
|
|
|
|
#
|
|
|
|
# Redistribution and use is allowed according to the terms of the New
|
|
|
|
# BSD license.
|
|
|
|
#
|
|
|
|
|
|
|
|
# use pkg-config to get the directories and then use these values
|
|
|
|
# in the FIND_PATH() and FIND_LIBRARY() calls
|
2017-10-26 03:42:42 +02:00
|
|
|
find_package(PkgConfig QUIET)
|
2017-09-13 13:09:40 +02:00
|
|
|
if (PKG_CONFIG_FOUND)
|
2017-10-26 03:42:42 +02:00
|
|
|
pkg_check_modules(_FFMPEG_AVCODEC libavcodec QUIET)
|
|
|
|
pkg_check_modules(_FFMPEG_AVFORMAT libavformat QUIET)
|
|
|
|
pkg_check_modules(_FFMPEG_AVUTIL libavutil QUIET)
|
2018-07-03 21:06:49 +02:00
|
|
|
pkg_check_modules(_FFMPEG_SWRESAMPLE libswresample QUIET)
|
2017-09-13 13:09:40 +02:00
|
|
|
endif (PKG_CONFIG_FOUND)
|
|
|
|
|
|
|
|
find_path(FFMPEG_AVCODEC_INCLUDE_DIR
|
|
|
|
NAMES libavcodec/avcodec.h
|
|
|
|
PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
|
|
|
|
PATH_SUFFIXES ffmpeg libav
|
|
|
|
)
|
|
|
|
|
|
|
|
find_library(FFMPEG_LIBAVCODEC
|
|
|
|
NAMES avcodec
|
|
|
|
PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
|
|
|
)
|
|
|
|
|
|
|
|
find_library(FFMPEG_LIBAVFORMAT
|
|
|
|
NAMES avformat
|
|
|
|
PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
|
|
|
)
|
|
|
|
|
|
|
|
find_library(FFMPEG_LIBAVUTIL
|
|
|
|
NAMES avutil
|
|
|
|
PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
|
|
|
)
|
|
|
|
|
|
|
|
if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
|
|
|
|
set(FFMPEG_FOUND TRUE)
|
|
|
|
endif()
|
|
|
|
|
2017-11-05 14:47:03 +01:00
|
|
|
find_library(FFMPEG_SWRESAMPLE
|
|
|
|
NAMES swresample
|
|
|
|
PATHS ${_FFMPEG_SWRESAMPLE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
|
|
|
)
|
|
|
|
|
2017-09-13 13:09:40 +02:00
|
|
|
set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})
|
|
|
|
|
|
|
|
set(FFMPEG_LIBRARIES
|
|
|
|
${FFMPEG_LIBAVCODEC}
|
|
|
|
${FFMPEG_LIBAVFORMAT}
|
|
|
|
${FFMPEG_LIBAVUTIL}
|
2018-07-03 21:06:49 +02:00
|
|
|
${FFMPEG_SWRESAMPLE}
|
2017-09-13 13:09:40 +02:00
|
|
|
)
|
|
|
|
|
2017-11-05 14:47:03 +01:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
list(APPEND FFMPEG_LIBRARIES "${FFMPEG_SWRESAMPLE}" secur32.lib Ws2_32.lib)
|
|
|
|
endif()
|
|
|
|
|
2017-10-26 03:42:42 +02:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(FFmpeg DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIR)
|
2018-06-24 00:43:06 +02:00
|
|
|
|
|
|
|
if(FFMPEG_FOUND)
|
|
|
|
add_library(ffmpeg INTERFACE)
|
|
|
|
target_link_libraries(ffmpeg
|
|
|
|
INTERFACE
|
|
|
|
${FFMPEG_LIBRARIES}
|
|
|
|
)
|
|
|
|
target_include_directories(ffmpeg SYSTEM
|
|
|
|
INTERFACE
|
|
|
|
"${FFMPEG_INCLUDE_DIR}"
|
|
|
|
)
|
|
|
|
add_library(ffmpeg::ffmpeg ALIAS ffmpeg)
|
|
|
|
endif()
|