]> git.sesse.net Git - vlc/blob - extras/buildsystem/cmake/include/FindFFmpeg.cmake
cmake: FindFFmpeg simplication.
[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               set(FFmpeg_LIBRARIES "${library};${FFmpeg_LIBRARIES}")
23               set(FFmpeg_FOUND TRUE CACHE INTERNAL "")
24             endif (${library}_LIBRARY)
25         endforeach (library)
26         foreach (library a52 faac lame z png mp3lame twolame)
27             find_library( ${library}_LIBRARY ${library} )
28             if (${library}_LIBRARY)
29               set(FFmpeg_LIBRARIES "${library};${FFmpeg_LIBRARIES}")
30             endif (${library}_LIBRARY)
31         endforeach (library)
32         set(FFmpeg_LIBRARIES "${FFmpeg_LIBRARIES}" CACHE INTERNAL STRING)
33     endif (NOT FFmpeg_FOUND)
34
35     if (FFmpeg_FOUND)
36       if (NOT FFmpeg_FIND_QUIETLY)
37         message(STATUS "Found FFmpeg in: ${FFmpeg_LIBRARIES}")
38       endif (NOT FFmpeg_FIND_QUIETLY)
39     else (FFmpeg_FOUND)
40       if (FFmpeg_FIND_REQUIRED)
41         message(FATAL_ERROR "Could not find the library containing FFmpeg")
42       endif (FFmpeg_FIND_REQUIRED)
43     endif (FFmpeg_FOUND)
44
45     mark_as_advanced(FFmpeg_LIBRARIES)
46 endif(NOT FFmpeg_SEARCHED)