cmake_modules/FindFFMPEG.cmake
author sheepluva
Fri, 12 Oct 2012 11:02:43 +0200
changeset 7747 8df97e271e5e
parent 7617 0ac281e1b58b
child 7816 a25e943dd4b0
permissions -rw-r--r--
add Randy to extended credits
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7534
ccb9c2906160 fix FindFFMPEG
Stepan777 <stepik-777@mail.ru>
parents: 7528
diff changeset
     1
# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil)
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     2
# Once done this will define
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     3
#
7540
cc6c656f70b5 cmake scripts
Stepan777 <stepik-777@mail.ru>
parents: 7538
diff changeset
     4
#  FFMPEG_FOUND - system has ffmpeg or libav
7534
ccb9c2906160 fix FindFFMPEG
Stepan777 <stepik-777@mail.ru>
parents: 7528
diff changeset
     5
#  FFMPEG_INCLUDE_DIR - the ffmpeg include directory
ccb9c2906160 fix FindFFMPEG
Stepan777 <stepik-777@mail.ru>
parents: 7528
diff changeset
     6
#  FFMPEG_LIBRARIES - Link these to use ffmpeg
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
     7
#  FFMPEG_LIBAVCODEC
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
     8
#  FFMPEG_LIBAVFORMAT
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
     9
#  FFMPEG_LIBAVUTIL
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    10
#
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    11
#  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    12
#  Modified for other libraries by Lasse Kärkkäinen <tronic>
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    13
#  Modified for Hedgewars by Stepik777
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    14
#
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    15
#  Redistribution and use is allowed according to the terms of the New
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    16
#  BSD license.
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    17
#
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    18
7534
ccb9c2906160 fix FindFFMPEG
Stepan777 <stepik-777@mail.ru>
parents: 7528
diff changeset
    19
if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    20
  # in cache already
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    21
  set(FFMPEG_FOUND TRUE)
7534
ccb9c2906160 fix FindFFMPEG
Stepan777 <stepik-777@mail.ru>
parents: 7528
diff changeset
    22
else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    23
  # use pkg-config to get the directories and then use these values
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    24
  # in the FIND_PATH() and FIND_LIBRARY() calls
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    25
  find_package(PkgConfig)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    26
  if (PKG_CONFIG_FOUND)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    27
    pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    28
    pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    29
    pkg_check_modules(_FFMPEG_AVUTIL libavutil)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    30
  endif (PKG_CONFIG_FOUND)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    31
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    32
  find_path(FFMPEG_AVCODEC_INCLUDE_DIR
7534
ccb9c2906160 fix FindFFMPEG
Stepan777 <stepik-777@mail.ru>
parents: 7528
diff changeset
    33
    NAMES libavcodec/avcodec.h
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    34
    PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
7534
ccb9c2906160 fix FindFFMPEG
Stepan777 <stepik-777@mail.ru>
parents: 7528
diff changeset
    35
    PATH_SUFFIXES ffmpeg libav
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    36
  )
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    37
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
    38
  find_library(FFMPEG_LIBAVCODEC
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    39
    NAMES avcodec
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    40
    PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    41
  )
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    42
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
    43
  find_library(FFMPEG_LIBAVFORMAT
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    44
    NAMES avformat
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    45
    PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    46
  )
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    47
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
    48
  find_library(FFMPEG_LIBAVUTIL
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    49
    NAMES avutil
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    50
    PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    51
  )
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    52
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
    53
  if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    54
    set(FFMPEG_FOUND TRUE)
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
    55
  endif()
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    56
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    57
  if (FFMPEG_FOUND)
7617
0ac281e1b58b Make ffmpeg optional for frontend
unc0rr
parents: 7540
diff changeset
    58
    set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    59
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    60
    set(FFMPEG_LIBRARIES
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
    61
      ${FFMPEG_LIBAVCODEC}
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
    62
      ${FFMPEG_LIBAVFORMAT}
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
    63
      ${FFMPEG_LIBAVUTIL}
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    64
    )
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    65
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    66
  endif (FFMPEG_FOUND)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    67
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    68
  if (FFMPEG_FOUND)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    69
    if (NOT FFMPEG_FIND_QUIETLY)
7540
cc6c656f70b5 cmake scripts
Stepan777 <stepik-777@mail.ru>
parents: 7538
diff changeset
    70
      message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    71
    endif (NOT FFMPEG_FIND_QUIETLY)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    72
  else (FFMPEG_FOUND)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    73
    if (FFMPEG_FIND_REQUIRED)
7540
cc6c656f70b5 cmake scripts
Stepan777 <stepik-777@mail.ru>
parents: 7538
diff changeset
    74
      message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil")
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    75
    endif (FFMPEG_FIND_REQUIRED)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    76
  endif (FFMPEG_FOUND)
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    77
7534
ccb9c2906160 fix FindFFMPEG
Stepan777 <stepik-777@mail.ru>
parents: 7528
diff changeset
    78
endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
7528
f8cf277dca36 FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    79