1# - Find FFmpeg library and includes. 2# Set FFMPEG_FIND_COMPONENTS to the canonical names of the libraries 3# before using the module. 4# This module defines 5# FFMPEG_INCLUDE_DIRS, where to find libavcodec/ac3_parser.h. 6# FFMPEG_LIBRARIES, libraries to link against to use FFmpeg. 7# FFMPEG_ROOT_DIR, The base directory to search for FFmpeg. 8# This can also be an environment variable. 9# FFMPEG_FOUND, If false, do not try to use FFmpeg. 10# FFMPEG_<COMPONENT>_LIBRARY, the given individual component libraries. 11#============================================================================= 12# Copyright 2020 Blender Foundation. 13# 14# Distributed under the OSI-approved BSD 3-Clause License, 15# see accompanying file BSD-3-Clause-license.txt for details. 16#============================================================================= 17 18# If FFMPEG_ROOT_DIR was defined in the environment, use it. 19if(NOT FFMPEG_ROOT_DIR AND NOT $ENV{FFMPEG_ROOT_DIR} STREQUAL "") 20 set(FFMPEG_ROOT_DIR $ENV{FFMPEG_ROOT_DIR}) 21endif() 22 23set(_ffmpeg_SEARCH_DIRS 24 ${FFMPEG_ROOT_DIR} 25 /opt/lib/ffmpeg 26) 27 28if(NOT FFMPEG_FIND_COMPONENTS) 29 set(FFMPEG_FIND_COMPONENTS 30 # List taken from http://ffmpeg.org/download.html#build-mac 31 avcodec 32 avdevice 33 avfilter 34 avformat 35 avutil 36 ) 37endif() 38 39find_path(_ffmpeg_INCLUDE_DIR 40 NAMES 41 libavcodec/ac3_parser.h 42 HINTS 43 ${_ffmpeg_SEARCH_DIRS} 44 PATH_SUFFIXES 45 include 46) 47 48set(_ffmpeg_LIBRARIES) 49foreach(_component ${FFMPEG_FIND_COMPONENTS}) 50 string(TOUPPER ${_component} _upper_COMPONENT) 51 find_library(FFMPEG_${_upper_COMPONENT}_LIBRARY 52 NAMES 53 ${_upper_COMPONENT} 54 HINTS 55 ${LIBDIR}/ffmpeg 56 PATH_SUFFIXES 57 lib64 lib 58 ) 59 if(NOT FFMPEG_${_upper_COMPONENT}_LIBRARY) 60 message(WARNING "Could NOT find FFmpeg ${_upper_COMPONENT}.") 61 endif() 62 list(APPEND _ffmpeg_LIBRARIES ${FFMPEG_${_upper_COMPONENT}_LIBRARY}) 63 mark_as_advanced(FFMPEG_${_upper_COMPONENT}_LIBRARY) 64endforeach() 65 66# handle the QUIETLY and REQUIRED arguments and set FFMPEG_FOUND to TRUE if 67# all listed variables are TRUE 68include(FindPackageHandleStandardArgs) 69find_package_handle_standard_args(FFmpeg DEFAULT_MSG 70 _ffmpeg_LIBRARIES _ffmpeg_INCLUDE_DIR) 71 72IF(FFMPEG_FOUND) 73 set(FFMPEG_LIBRARIES ${_ffmpeg_LIBRARIES}) 74 set(FFMPEG_INCLUDE_DIRS ${_ffmpeg_INCLUDE_DIR}) 75ENDIF() 76 77mark_as_advanced( 78 FFMPEG_INCLUDE_DIR 79) 80 81unset(_ffmpeg_SEARCH_DIRS) 82unset(_ffmpeg_LIBRARIES) 83unset(_ffmpeg_INCLUDE_DIR) 84