]> git.sesse.net Git - vlc/blob - extras/buildsystem/cmake/include/FindFFmpeg.cmake
7784b665c910c1388c0a9112ec434724e092ce19
[vlc] / extras / buildsystem / cmake / include / FindFFmpeg.cmake
1 # - Find library containing FFmpeg()
2 # The following variables are set if FFmpeg is found. If FFmpeg is not
3 # found, FFmpeg_FOUND is set to false.
4 #  FFmpeg_FOUND     - System has FFmpeg.
5 #  FFmpeg_LIBRARIES - Link these to use FFmpeg.
6 #  FFmpeg_CFLAGS - Link these to use FFmpeg.
7
8
9 if (NOT FFmpeg_SEARCHED)
10     include(CheckLibraryExists)
11
12     set(FFmpeg_SEARCHED TRUE CACHE INTERNAL "")
13     set(FFmpeg_FOUND FALSE CACHE INTERNAL "")
14
15     pkg_check_modules(FFmpeg libffmpeg)
16
17     if (NOT FFmpeg_FOUND)
18         set(FFmpeg_LIBRARIES "")
19         foreach (library ffmpeg avcodec avformat avutil postproc swscale)
20             find_library( ${library}_LIBRARY ${library} )
21             if (${library}_LIBRARY)
22               pkg_check_modules(${library}_LIBRARY lib${library})
23               set(FFmpeg_CFLAGS "${FFmpeg_CFLAGS} ${${library}_LIBRARY_CFLAGS}")
24               set(FFmpeg_LIBRARIES "${library};${FFmpeg_LIBRARIES}")
25               set(FFmpeg_FOUND TRUE CACHE INTERNAL "")
26             endif (${library}_LIBRARY)
27         endforeach (library)
28         foreach (library a52 faac lame z png mp3lame twolame)
29             find_library( ${library}_LIBRARY ${library} )
30             if (${library}_LIBRARY)
31               pkg_check_modules(${library}_LIBRARY lib${library})
32               set(FFmpeg_CFLAGS "${FFmpeg_CFLAGS} ${${library}_LIBRARY_CFLAGS}")
33               set(FFmpeg_LIBRARIES "${library};${FFmpeg_LIBRARIES}")
34             endif (${library}_LIBRARY)
35         endforeach (library)
36         set(FFmpeg_LIBRARIES "${FFmpeg_LIBRARIES}" CACHE INTERNAL STRING)
37     endif (NOT FFmpeg_FOUND)
38
39     if (FFmpeg_FOUND)
40       if (NOT FFmpeg_FIND_QUIETLY)
41         message(STATUS "Found FFmpeg in: ${FFmpeg_LIBRARIES}")
42       endif (NOT FFmpeg_FIND_QUIETLY)
43     else (FFmpeg_FOUND)
44       if (FFmpeg_FIND_REQUIRED)
45         message(FATAL_ERROR "Could not find the library containing FFmpeg")
46       endif (FFmpeg_FIND_REQUIRED)
47     endif (FFmpeg_FOUND)
48
49     mark_as_advanced(FFmpeg_LIBRARIES)
50 endif(NOT FFmpeg_SEARCHED)