Moar cmake stuff.
[sdlpango.git] / cmake / FindFFmpeg.cmake
blobf45167ab44953caf2938f2d3177d9bb58ff8f44c
1 # - Try to find libxml++-2.6
2 # Once done this will define
4 #  FFMPEG_FOUND - system has libxml++
5 #  FFMPEG_INCLUDE_DIRS - the libxml++ include directory
6 #  FFMPEG_LIBRARIES - Link these to use libxml++
7 #  FFMPEG_DEFINITIONS - Compiler switches required for using libxml++
9 #  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
10 #  Modified for other libraries by Lasse Kärkkäinen <tronic>
12 #  Redistribution and use is allowed according to the terms of the New
13 #  BSD license.
14 #  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
17 if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
18   # in cache already
19   set(FFMPEG_FOUND TRUE)
20 else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
21   # use pkg-config to get the directories and then use these values
22   # in the FIND_PATH() and FIND_LIBRARY() calls
23   find_package(PkgConfig)
24   if (PKG_CONFIG_FOUND)
25     pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
26     pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
27     pkg_check_modules(_FFMPEG_SWSCALE libswscale)
28   endif (PKG_CONFIG_FOUND)
30   find_path(FFMPEG_AVCODEC_INCLUDE_DIR
31     NAMES avcodec.h
32     PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
33     PATH_SUFFIXES ffmpeg libavcodec
34   )
36   find_path(FFMPEG_AVFORMAT_INCLUDE_DIR
37     NAMES avformat.h
38     PATHS ${_FFMPEG_AVFORMAT_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
39     PATH_SUFFIXES ffmpeg libavformat
40   )
42   find_path(FFMPEG_SWSCALE_INCLUDE_DIR
43     NAMES swscale.h
44     PATHS ${_FFMPEG_SWSCALE_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
45     PATH_SUFFIXES ffmpeg libswscale
46   )
47   
48   find_library(FFMPEG_AVCODEC_LIBRARY
49     NAMES avcodec
50     PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
51   )
53   find_library(FFMPEG_AVFORMAT_LIBRARY
54     NAMES avformat
55     PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
56   )
58   find_library(FFMPEG_SWSCALE_LIBRARY
59     NAMES swscale
60     PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
61   )
63   if (FFMPEG_AVCODEC_LIBRARY AND FFMPEG_AVFORMAT_LIBRARY AND FFMPEG_SWSCALE_LIBRARY)
64     set(FFMPEG_FOUND TRUE)
65   endif (FFMPEG_AVCODEC_LIBRARY AND FFMPEG_AVFORMAT_LIBRARY AND FFMPEG_SWSCALE_LIBRARY)
67   if (FFMPEG_FOUND)
69     set(FFMPEG_INCLUDE_DIRS
70       ${FFMPEG_AVCODEC_INCLUDE_DIR}
71       ${FFMPEG_AVFORMAT_INCLUDE_DIR}
72       ${FFMPEG_SWSCALE_INCLUDE_DIR}
73     )
75     set(FFMPEG_LIBRARIES
76       ${FFMPEG_AVCODEC_LIBRARY}
77       ${FFMPEG_AVFORMAT_LIBRARY}
78       ${FFMPEG_SWSCALE_LIBRARY}
79     )
81   endif (FFMPEG_FOUND)
83   if (FFMPEG_FOUND)
84     if (NOT FFMPEG_FIND_QUIETLY)
85       message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}")
86     endif (NOT FFMPEG_FIND_QUIETLY)
87   else (FFMPEG_FOUND)
88     if (FFMPEG_FIND_REQUIRED)
89       message(FATAL_ERROR "Could not find FFMPEG libavcodec, libavformat or libswscale")
90     endif (FFMPEG_FIND_REQUIRED)
91   endif (FFMPEG_FOUND)
93   # show the FFMPEG_INCLUDE_DIRS and FFMPEG_LIBRARIES variables only in the advanced view
94   mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES)
96 endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)