cmake_modules/FindFFMPEG.cmake
author dag10
Mon, 14 Jan 2013 11:19:59 +0100
changeset 8377 869f80966a77
parent 8285 a1500ffdc343
child 8662 bfcc09f2accc
permissions -rw-r--r--
GCI2012: Improve Game Configuration Widget - Refactored mapmodel+datamanager to have two separate map models for static and mission maps, and then three static MapInfos in MapModel for the three special maps (random, maze, drawn). - Created theme selector dialog. - Created seed view/edit dialog. - Enlarged start icon on pagemultiplayer and pagenetgame, and added Start.png. - Moved "Settings" button on pagemultiplayer and pagenetgame from middle of page to page footer. - Added "load drawing" button to mapcontainer widget. - Map preview is no longer the randomize button; The randomize functionality is now in a button of its own. - Map preview no longer grays out (isn't disabled) when in slave mode. - Seed is now viewable and copyable when in slave mode -- but not editable. - You should now use the property master (isMaster() and setMaster()) on gamecfgwidget and mapcontainer instead of the enabled property. This is because some widgets (e.g. "view/edit seed" button and map preview) shouldn't be disabled, when all other widgets should be. - Added mission map descriptions w/ locale support in INI format in mapname/desc.txt if applicable. Use '|' for line break.

# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil)
# Once done this will define
#
#  FFMPEG_FOUND - system has ffmpeg or libav
#  FFMPEG_INCLUDE_DIR - the ffmpeg include directory
#  FFMPEG_LIBRARIES - Link these to use ffmpeg
#  FFMPEG_LIBAVCODEC
#  FFMPEG_LIBAVFORMAT
#  FFMPEG_LIBAVUTIL
#
#  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
#  Modified for other libraries by Lasse Kärkkäinen <tronic>
#  Modified for Hedgewars by Stepik777
#
#  Redistribution and use is allowed according to the terms of the New
#  BSD license.
#

set(FFMPEG_FOUND FALSE)

if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
  # in cache already
  set(FFMPEG_FOUND TRUE)
else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
  # silence output option
  if (FFMPEG_FIND_QUIETLY)
    set(VERBOSITY "QUIET")
  endif ()
  # use pkg-config to get the directories and then use these values
  # in the FIND_PATH() and FIND_LIBRARY() calls
  find_package(PkgConfig)
  if (PKG_CONFIG_FOUND)
    pkg_check_modules(_FFMPEG_AVCODEC libavcodec ${VERBOSITY})
    pkg_check_modules(_FFMPEG_AVFORMAT libavformat ${VERBOSITY})
    pkg_check_modules(_FFMPEG_AVUTIL libavutil ${VERBOSITY})
  endif (PKG_CONFIG_FOUND)

  find_path(FFMPEG_AVCODEC_INCLUDE_DIR
    NAMES libavcodec/avcodec.h
    PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS}
        /usr/include /usr/local/include #system level
        /opt/local/include #macports
        /sw/include #fink
    PATH_SUFFIXES ffmpeg libav
  )

  find_library(FFMPEG_LIBAVCODEC
    NAMES avcodec
    PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS}
        /usr/lib /usr/local/lib #system level
        /opt/local/lib #macports
        /sw/lib #fink
  )

  find_library(FFMPEG_LIBAVFORMAT
    NAMES avformat
    PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS}
        /usr/lib /usr/local/lib #system level
        /opt/local/lib #macports
        /sw/lib #fink
  )

  find_library(FFMPEG_LIBAVUTIL
    NAMES avutil
    PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS}
        /usr/lib /usr/local/lib #system level
        /opt/local/lib #macports
        /sw/lib #fink
  )

  if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
    set(FFMPEG_FOUND TRUE)
  endif()

  if (FFMPEG_FOUND)
    set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})

    set(FFMPEG_LIBRARIES
      ${FFMPEG_LIBAVCODEC}
      ${FFMPEG_LIBAVFORMAT}
      ${FFMPEG_LIBAVUTIL}
    )
  endif (FFMPEG_FOUND)

  if (FFMPEG_FOUND)
    if (NOT FFMPEG_FIND_QUIETLY)
      message(STATUS "Found FFMPEG/LibAV: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
    endif (NOT FFMPEG_FIND_QUIETLY)
  else (FFMPEG_FOUND)
    if (FFMPEG_FIND_REQUIRED)
      message(FATAL_ERROR "Could NOT find libavcodec or libavformat or libavutil")
    endif (FFMPEG_FIND_REQUIRED)
  endif (FFMPEG_FOUND)

endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)