cmake_modules/FindFFMPEG.cmake
changeset 9959 1a42d36f346a
parent 9957 7a62f31895ac
child 9961 c18c66d621e5
equal deleted inserted replaced
9957:7a62f31895ac 9959:1a42d36f346a
     1 # Find ffmpeg/libav libraries (libavcodec, libavformat and libavutil)
       
     2 # Once done this will define
       
     3 #
       
     4 #  FFMPEG_FOUND             - system has libavcodec, libavformat, libavutil
       
     5 #  FFMPEG_INCLUDE_DIR       - the libav include directories
       
     6 #  FFMPEG_LIBRARIES         - the libav libraries
       
     7 #
       
     8 #  LIBAVCODEC_LIBRARY      - the libavcodec library
       
     9 #  LIBAVCODEC_INCLUDE_DIR  - the libavcodec include directory
       
    10 #  LIBAVFORMAT_LIBRARY     - the libavformat library
       
    11 #  LIBAVUTIL_LIBRARY       - the libavutil library
       
    12 #
       
    13 #  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
       
    14 #  Modified for other libraries by Lasse Kärkkäinen <tronic>
       
    15 #  Modified for Hedgewars by Stepik777
       
    16 #  Copyright (c) 2013 Vittorio Giovara <vittorio.giovara@gmail.com>
       
    17 #
       
    18 #  Redistribution and use is allowed according to the terms of the New
       
    19 #  BSD license.
       
    20 #
       
    21 
       
    22 include(FindPackageHandleStandardArgs)
       
    23 
       
    24 
       
    25 # use pkg-config to get the directories and then use these values
       
    26 # in the FIND_PATH() and FIND_LIBRARY() calls
       
    27 find_package(PkgConfig)
       
    28 if(PKG_CONFIG_FOUND)
       
    29     if(NOT LIBAVCODEC_INCLUDE_DIR OR NOT LIBAVCODEC_LIBRARY)
       
    30         pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
       
    31     endif()
       
    32     if(NOT LIBAVFORMAT_LIBRARY)
       
    33         pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
       
    34     endif()
       
    35     if(NOT LIBAVUTIL_LIBRARY)
       
    36         pkg_check_modules(_FFMPEG_AVUTIL libavutil)
       
    37     endif()
       
    38 endif(PKG_CONFIG_FOUND)
       
    39 
       
    40 find_path(LIBAVCODEC_INCLUDE_DIR
       
    41     NAMES libavcodec/avcodec.h
       
    42     PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS}    #pkg-config
       
    43           /usr/include /usr/local/include    #system level
       
    44           /opt/local/include /sw/include     #macports & fink
       
    45     PATH_SUFFIXES libav ffmpeg
       
    46 )
       
    47 
       
    48 #TODO: add other include paths
       
    49 
       
    50 find_library(LIBAVCODEC_LIBRARY
       
    51     NAMES avcodec
       
    52     PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS}   #pkg-config
       
    53           /usr/lib /usr/local/lib           #system level
       
    54           /opt/local/lib /sw/lib            #macports & fink
       
    55 )
       
    56 
       
    57 find_library(LIBAVFORMAT_LIBRARY
       
    58     NAMES avformat
       
    59     PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS}  #pkg-config
       
    60           /usr/lib /usr/local/lib           #system level
       
    61           /opt/local/lib /sw/lib            #macports & fink
       
    62 )
       
    63 
       
    64 find_library(LIBAVUTIL_LIBRARY
       
    65     NAMES avutil
       
    66     PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS}    #pkg-config
       
    67           /usr/lib /usr/local/lib           #system level
       
    68           /opt/local/lib /sw/lib            #macports & fink
       
    69 )
       
    70 
       
    71 find_package_handle_standard_args(FFMPEG DEFAULT_MSG LIBAVCODEC_LIBRARY LIBAVCODEC_INCLUDE_DIR
       
    72                                                      LIBAVFORMAT_LIBRARY
       
    73                                                      LIBAVUTIL_LIBRARY
       
    74                                                      )
       
    75 set(FFMPEG_INCLUDE_DIR ${LIBAVCODEC_INCLUDE_DIR}
       
    76                        #TODO: add other include paths
       
    77                        )
       
    78 set(FFMPEG_LIBRARIES ${LIBAVCODEC_LIBRARY}
       
    79                      ${LIBAVFORMAT_LIBRARY}
       
    80                      ${LIBAVUTIL_LIBRARY}
       
    81                      )
       
    82 
       
    83 mark_as_advanced(FFMPEG_INCLUDE_DIR FFMPEG_LIBRARIES LIBAVCODEC_LIBRARY LIBAVCODEC_INCLUDE_DIR LIBAVFORMAT_LIBRARY LIBAVUTIL_LIBRARY)
       
    84 
       
    85