cmake_modules/FindFFMPEG.cmake
changeset 7528 f8cf277dca36
child 7534 ccb9c2906160
equal deleted inserted replaced
7525:5c840e221993 7528:f8cf277dca36
       
     1 # - Try to find libxml++-2.6
       
     2 # Once done this will define
       
     3 #
       
     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++
       
     8 #
       
     9 #  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
       
    10 #  Modified for other libraries by Lasse Kärkkäinen <tronic>
       
    11 #  Modified for Hedgewars by Stepik777
       
    12 #
       
    13 #  Redistribution and use is allowed according to the terms of the New
       
    14 #  BSD license.
       
    15 #
       
    16 
       
    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_AVUTIL libavutil)
       
    28   endif (PKG_CONFIG_FOUND)
       
    29 
       
    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   )
       
    35 
       
    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   )
       
    41 
       
    42   find_library(FFMPEG_AVCODEC_LIBRARY
       
    43     NAMES avcodec
       
    44     PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
       
    45   )
       
    46 
       
    47   find_library(FFMPEG_AVFORMAT_LIBRARY
       
    48     NAMES avformat
       
    49     PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
       
    50   )
       
    51 
       
    52   find_library(FFMPEG_AVUTIL_LIBRARY
       
    53     NAMES avutil
       
    54     PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
       
    55   )
       
    56 
       
    57   if (FFMPEG_AVCODEC_LIBRARY AND FFMPEG_AVFORMAT_LIBRARY)
       
    58     set(FFMPEG_FOUND TRUE)
       
    59   endif (FFMPEG_AVCODEC_LIBRARY AND FFMPEG_AVFORMAT_LIBRARY)
       
    60 
       
    61   if (FFMPEG_FOUND)
       
    62 
       
    63     set(FFMPEG_INCLUDE_DIR
       
    64       ${FFMPEG_AVCODEC_INCLUDE_DIR}
       
    65       ${FFMPEG_AVFORMAT_INCLUDE_DIR}
       
    66     )
       
    67 
       
    68     set(FFMPEG_LIBRARIES
       
    69       ${FFMPEG_AVCODEC_LIBRARY}
       
    70       ${FFMPEG_AVFORMAT_LIBRARY}
       
    71       ${FFMPEG_AVUTIL_LIBRARY}
       
    72     )
       
    73 
       
    74   endif (FFMPEG_FOUND)
       
    75 
       
    76   if (FFMPEG_FOUND)
       
    77     if (NOT FFMPEG_FIND_QUIETLY)
       
    78       message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}")
       
    79     endif (NOT FFMPEG_FIND_QUIETLY)
       
    80   else (FFMPEG_FOUND)
       
    81     if (FFMPEG_FIND_REQUIRED)
       
    82       message(FATAL_ERROR "Could not find FFMPEG libavcodec, libavformat or libswscale")
       
    83     endif (FFMPEG_FIND_REQUIRED)
       
    84   endif (FFMPEG_FOUND)
       
    85 
       
    86 endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
       
    87