mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35:38 +00:00
Replaced the CMake find module for FFmpeg.
This commit is contained in:
parent
a1209dfc5d
commit
eb868055b7
|
@ -1,88 +1,108 @@
|
||||||
# Copyright (c) 2014 Matt Coffin <mcoffin13@gmail.com>
|
# Locate ffmpeg
|
||||||
|
# This module defines
|
||||||
|
# FFMPEG_LIBRARIES
|
||||||
|
# FFMPEG_FOUND, if false, do not try to link to ffmpeg
|
||||||
|
# FFMPEG_INCLUDE_DIR, where to find the headers
|
||||||
#
|
#
|
||||||
# This software is provided 'as-is', without any express or implied
|
# $FFMPEG_DIR is an environment variable that would
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
# correspond to the ./configure --prefix=$FFMPEG_DIR
|
||||||
# arising from the use of this software.
|
|
||||||
#
|
#
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
# Created by Robert Osfield.
|
||||||
# including commercial applications, and to alter it and redistribute it
|
# Modified by Lukas Lalinsky.
|
||||||
# freely, subject to the following restrictions:
|
|
||||||
#
|
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
# claim that you wrote the original software. If you use this software
|
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
|
||||||
# appreciated but is not required.
|
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
# misrepresented as being the original software.
|
|
||||||
# 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
|
|
||||||
# - Try to find FFmpeg
|
# In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>"
|
||||||
# Once done this will define
|
# In OSG ffmpeg plugin, we use "#include <header.h>" for compatibility with old version of ffmpeg
|
||||||
# FFmpeg_FOUND
|
|
||||||
# FFmpeg_INCLUDE_DIRS
|
|
||||||
# FFmpeg_LIBRARIES
|
|
||||||
# FFmpeg_INCLUDE_FILES
|
|
||||||
# Author: Matt Coffin <mcoffin13@gmail.com>
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
# We have to search the path which contain the header.h (usefull for old version)
|
||||||
|
# and search the path which contain the libname/header.h (usefull for new version)
|
||||||
|
|
||||||
if (NOT FFmpeg_FIND_COMPONENTS)
|
# Then we need to include ${FFMPEG_libname_INCLUDE_DIRS}
|
||||||
set(FFmpeg_FIND_COMPONENTS avcodec avformat avutil swresample swscale)
|
# (in old version case, use by ffmpeg header and osg plugin code)
|
||||||
endif(NOT FFmpeg_FIND_COMPONENTS)
|
# (in new version case, use by ffmpeg header)
|
||||||
|
# and ${FFMPEG_libname_INCLUDE_DIRS/libname}
|
||||||
|
# (in new version case, use by osg plugin code)
|
||||||
|
|
||||||
# Generate component include files and requirements
|
# Macro to find header and lib directories
|
||||||
foreach(comp ${FFmpeg_FIND_COMPONENTS})
|
# example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
|
||||||
if(FFmpeg_FIND_REQUIRED_${comp})
|
MACRO(FFMPEG_FIND varname shortname headername)
|
||||||
list(APPEND required "FFmpeg_${comp}_FOUND")
|
|
||||||
endif()
|
|
||||||
endforeach(comp)
|
|
||||||
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
|
||||||
set(_lib_suffix 64)
|
|
||||||
else()
|
|
||||||
set(_lib_suffix 32)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(FFMPEG_PATH_ARCH FFmpegPath${_lib_suffix})
|
|
||||||
# Find libraries
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
foreach(comp ${FFmpeg_FIND_COMPONENTS})
|
|
||||||
if(PKG_CONFIG_FOUND)
|
|
||||||
pkg_check_modules(_${comp} QUIET lib${comp})
|
|
||||||
endif()
|
|
||||||
find_path(FFmpeg_${comp}_INCLUDE_DIR
|
|
||||||
NAMES "lib${comp}/${comp}.h"
|
|
||||||
HINTS
|
|
||||||
${_${comp}_INCLUDE_DIRS}
|
|
||||||
ENV FFmpegPath
|
|
||||||
ENV ${FFMPEG_PATH_ARCH}
|
|
||||||
PATHS
|
PATHS
|
||||||
/usr/include /usr/local/include /opt/local/include /sw/include
|
${FFMPEG_ROOT}/include
|
||||||
PATH_SUFFIXES ffmpeg libav
|
$ENV{FFMPEG_DIR}/include
|
||||||
DOC "FFmpeg include directory")
|
~/Library/Frameworks
|
||||||
find_library(FFmpeg_${comp}_LIBRARY
|
/Library/Frameworks
|
||||||
NAMES ${comp} ${comp}-ffmpeg ${_${comp}_LIBRARIES}
|
/usr/local/include
|
||||||
HINTS
|
/usr/include/
|
||||||
${_${comp}_LIBRARY_DIRS}
|
/sw/include # Fink
|
||||||
"${FFmpeg_${comp}_INCLUDE_DIR}/../lib"
|
/opt/local/include # DarwinPorts
|
||||||
"${FFmpeg_${comp}_INCLUDE_DIR}/../lib${_lib_suffix}"
|
/opt/csw/include # Blastwave
|
||||||
"${FFmpeg_${comp}_INCLUDE_DIR}/../libs${_lib_suffix}"
|
/opt/include
|
||||||
"${FFmpeg_${comp}_INCLUDE_DIR}/lib"
|
/usr/freeware/include
|
||||||
"${FFmpeg_${comp}_INCLUDE_DIR}/lib${_lib_suffix}"
|
NO_DEFAULT_PATH
|
||||||
PATHS
|
PATH_SUFFIXES ffmpeg
|
||||||
/usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
DOC "Location of FFMPEG Headers"
|
||||||
PATH_SUFFIXES ${comp} lib${comp}
|
)
|
||||||
DOC "FFmpeg ${comp} library")
|
FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
|
||||||
find_package_handle_standard_args(FFmpeg_${comp}
|
PATH_SUFFIXES ffmpeg
|
||||||
FOUND_VAR FFmpeg_${comp}_FOUND
|
DOC "Location of FFMPEG Headers"
|
||||||
REQUIRED_VARS FFmpeg_${comp}_LIBRARY FFmpeg_${comp}_INCLUDE_DIR)
|
)
|
||||||
if(${FFmpeg_${comp}_FOUND})
|
|
||||||
list(APPEND FFmpeg_INCLUDE_DIRS ${FFmpeg_${comp}_INCLUDE_DIR})
|
|
||||||
list(APPEND FFmpeg_LIBRARIES ${FFmpeg_${comp}_LIBRARY})
|
|
||||||
endif()
|
|
||||||
endforeach(comp)
|
|
||||||
|
|
||||||
# Run checks via find_package_handle_standard_args
|
pkg_check_modules(FFMPEG_${varname} lib${shortname})
|
||||||
find_package_handle_standard_args(FFmpeg
|
|
||||||
FOUND_VAR FFmpeg_FOUND
|
IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
|
||||||
REQUIRED_VARS ${required} FFmpeg_INCLUDE_DIRS FFmpeg_LIBRARIES)
|
SET(FFMPEG_${varname}_FOUND 1)
|
||||||
|
ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
ENDMACRO(FFMPEG_FIND)
|
||||||
|
|
||||||
|
SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
|
||||||
|
|
||||||
|
# find stdint.h
|
||||||
|
FIND_PATH(FFMPEG_STDINT_INCLUDE_DIR stdint.h
|
||||||
|
PATHS
|
||||||
|
${FFMPEG_ROOT}/include
|
||||||
|
$ENV{FFMPEG_DIR}/include
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local/include
|
||||||
|
/usr/include
|
||||||
|
/sw/include # Fink
|
||||||
|
/opt/local/include # DarwinPorts
|
||||||
|
/opt/csw/include # Blastwave
|
||||||
|
/opt/include
|
||||||
|
/usr/freeware/include
|
||||||
|
PATH_SUFFIXES ffmpeg
|
||||||
|
DOC "Location of FFMPEG stdint.h Header"
|
||||||
|
)
|
||||||
|
|
||||||
|
FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
|
||||||
|
FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
|
||||||
|
FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
|
||||||
|
FFMPEG_FIND(LIBAVCODEC_FFT avcodec avfft.h)
|
||||||
|
FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
|
||||||
|
FFMPEG_FIND(LIBSWRESAMPLE swresample swresample.h)
|
||||||
|
FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # Not sure about the header to look for here.
|
||||||
|
|
||||||
|
SET(FFMPEG_FOUND "NO")
|
||||||
|
|
||||||
|
IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND
|
||||||
|
FFMPEG_LIBAVUTIL_FOUND AND FFMPEG_LIBSWRESAMPLE_FOUND AND FFMPEG_LIBSWSCALE_FOUND AND
|
||||||
|
FFMPEG_STDINT_INCLUDE_DIR)
|
||||||
|
|
||||||
|
SET(FFMPEG_FOUND "YES")
|
||||||
|
SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
|
||||||
|
SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
|
||||||
|
|
||||||
|
SET(FFMPEG_LIBRARIES
|
||||||
|
${FFMPEG_LIBAVFORMAT_LIBRARIES}
|
||||||
|
${FFMPEG_LIBAVDEVICE_LIBRARIES}
|
||||||
|
${FFMPEG_LIBAVCODEC_LIBRARIES}
|
||||||
|
${FFMPEG_LIBAVUTIL_LIBRARIES}
|
||||||
|
${FFMPEG_LIBSWRESAMPLE_LIBRARIES}
|
||||||
|
${FFMPEG_LIBSWSCALE_LIBRARIES})
|
||||||
|
ELSE ()
|
||||||
|
|
||||||
|
# MESSAGE(STATUS "Could not find FFMPEG")
|
||||||
|
|
||||||
|
ENDIF()
|
||||||
|
|
|
@ -282,7 +282,7 @@ endif()
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
set(COMMON_LIBRARIES
|
set(COMMON_LIBRARIES
|
||||||
${CURL_LIBRARIES}
|
${CURL_LIBRARIES}
|
||||||
${FFmpeg_LIBRARIES}
|
${FFMPEG_LIBRARIES}
|
||||||
${FreeImage_LIBRARIES}
|
${FreeImage_LIBRARIES}
|
||||||
${FREETYPE_LIBRARIES}
|
${FREETYPE_LIBRARIES}
|
||||||
${PUGIXML_LIBRARIES}
|
${PUGIXML_LIBRARIES}
|
||||||
|
|
Loading…
Reference in a new issue