Index: cmake/modules/FindFFmpeg.cmake =================================================================== --- cmake/modules/FindFFmpeg.cmake (révision 1125744) +++ cmake/modules/FindFFmpeg.cmake (copie de travail) @@ -1,116 +1,107 @@ -# - Try to find ffmpeg -# Once done this will define -# -# FFMPEG_FOUND - system has ffmpeg -# FFMPEG_INCLUDE_DIR - Include directory necessary for using the ffmpeg headers -# FFMPEG_LIBRARIES - Link these to use ffmpeg -# FFMPEG_DEFINITIONS - Compiler switches required for using ffmpeg - -# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org> -# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org> -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -if (FFMPEG_LIBRARIES) - - # in cache already - set(FFMPEG_FOUND TRUE) - -else (FFMPEG_LIBRARIES) - -if (NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - find_package(PkgConfig) - pkg_check_modules(PC_LIBAVCODEC libavcodec) - set(FFMPEG_DEFINITIONS ${PC_LIBAVCODEC_CFLAGS_OTHER}) - -endif (NOT WIN32) - - # - # #include <libXXXX/XXXX.h> is the new style for FFMPEG headers - # This has been verified at least since 0.4.9 - # Please do not change to the old format, since this will break for - # people who are using newer versions. Instead, upgrade your ffmpeg - # installation. - # - find_path(FFMPEG_INCLUDE_DIR libavcodec/avcodec.h - HINTS - ${PC_LIBAVCODEC_INCLUDEDIR} - ${PC_LIBAVCODEC_INCLUDE_DIRS} - ) - - # also search for the old style include dir, just for the purpose - # of giving a useful error message if an old libavcodec is installed - # and the user might wonder why it is not found - find_path(FFMPEG_INCLUDE_DIR_OLD_STYLE ffmpeg/avcodec.h - HINTS - ${PC_LIBAVCODEC_INCLUDEDIR} - ${PC_LIBAVCODEC_INCLUDE_DIRS} - ) - - find_library(AVCODEC_LIBRARIES NAMES avcodec - HINTS - ${PC_LIBAVCODEC_LIBDIR} - ${PC_LIBAVCODEC_LIBRARY_DIRS} - ) - - find_library(AVFORMAT_LIBRARIES NAMES avformat - HINTS - ${PC_LIBAVCODEC_LIBDIR} - ${PC_LIBAVCODEC_LIBRARY_DIRS} - ) - - find_library(AVUTIL_LIBRARIES NAMES avutil - HINTS - ${PC_LIBAVCODEC_LIBDIR} - ${PC_LIBAVCODEC_LIBRARY_DIRS} - ) - - - - set(FFMPEG_LIBRARIES ) - if (AVCODEC_LIBRARIES) - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${AVCODEC_LIBRARIES}) - endif (AVCODEC_LIBRARIES) - - if (AVFORMAT_LIBRARIES) - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${AVFORMAT_LIBRARIES}) - endif (AVFORMAT_LIBRARIES) - - if (AVUTIL_LIBRARIES) - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${AVUTIL_LIBRARIES}) - endif (AVUTIL_LIBRARIES) - - if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) - set(FFMPEG_FOUND TRUE) - endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) - - if (FFMPEG_FOUND) - if (NOT FFmpeg_FIND_QUIETLY) - message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES} ${FFMPEG_INCLUDE_DIR}") - endif (NOT FFmpeg_FIND_QUIETLY) - else (FFMPEG_FOUND) - # only an old libavcodec was found ? - if (FFMPEG_INCLUDE_DIR_OLD_STYLE AND NOT FFMPEG_INCLUDE_DIR AND NOT FFmpeg_FIND_QUIETLY) - message(STATUS "Found old version of libavcodec, but a newer version is required.") - endif (FFMPEG_INCLUDE_DIR_OLD_STYLE AND NOT FFMPEG_INCLUDE_DIR AND NOT FFmpeg_FIND_QUIETLY) - - if (FFmpeg_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find FFMPEG") - else (FFmpeg_FIND_REQUIRED) - if (NOT FFmpeg_FIND_QUIETLY) - message(STATUS "Could NOT find FFMPEG") - endif (NOT FFmpeg_FIND_QUIETLY) - endif (FFmpeg_FIND_REQUIRED) - endif (FFMPEG_FOUND) - - mark_as_advanced(AVCODEC_LIBRARIES - AVFORMAT_LIBRARIES - AVUTIL_LIBRARIES - FFMPEG_INCLUDE_DIR - FFMPEG_INCLUDE_DIR_OLD_STYLE) - -endif (FFMPEG_LIBRARIES)# AND FFMPEG_DEFINITIONS) +# - Try to find FFMPEG +# Once done this will define +# +# FFMPEG_FOUND - system has FFMPEG +# FFMPEG_INCLUDE_DIR - the include directories +# FFMPEG_LIBRARY_DIR - the directory containing the libraries +# FFMPEG_LIBRARIES - link these to use FFMPEG +# FFMPEG_SWSCALE_FOUND - FFMPEG also has SWSCALE +# + +SET( FFMPEG_HEADERS avformat.h avcodec.h avutil.h avdevice.h ) +SET( FFMPEG_PATH_SUFFIXES libavformat libavcodec libavutil libavdevice ) +SET( FFMPEG_SWS_HEADERS swscale.h ) +SET( FFMPEG_SWS_PATH_SUFFIXES libswscale ) + +if( WIN32 ) + SET( FFMPEG_LIBRARIES avformat-52.lib avcodec-51.lib avutil-49.lib avdevice-52.lib ) + SET( FFMPEG_SWS_LIBRARIES swscale-0.lib ) + SET( FFMPEG_LIBRARY_DIR $ENV{FFMPEGDIR}\\lib ) + SET( FFMPEG_INCLUDE_PATHS $ENV{FFMPEGDIR}\\include ) + + # check to see if we can find swscale + SET( TMP_ TMP-NOTFOUND ) + FIND_PATH( TMP_ ${FFMPEG_SWS_LIBRARIES} + PATHS ${FFMPEG_LIBRARY_DIR} ) + IF ( TMP_ ) + SET( SWSCALE_FOUND TRUE ) + ENDIF( TMP_ ) +else( WIN32 ) + SET( FFMPEG_LIBRARIES avformat avcodec avutil avdevice ) + SET( FFMPEG_SWS_LIBRARIES swscale ) + INCLUDE(FindPkgConfig) + if ( PKG_CONFIG_FOUND ) + pkg_check_modules( AVFORMAT libavformat ) + pkg_check_modules( AVCODEC libavcodec ) + pkg_check_modules( AVUTIL libavutil ) + pkg_check_modules( AVDEVICE libavdevice ) + pkg_check_modules( SWSCALE libswscale ) + endif ( PKG_CONFIG_FOUND ) + + SET( FFMPEG_LIBRARY_DIR ${AVFORMAT_LIBRARY_DIRS} + ${AVCODEC_LIBRARY_DIRS} + ${AVUTIL_LIBRARY_DIRS} + ${AVDEVICE_LIBRARY_DIRS} ) + SET( FFMPEG_INCLUDE_PATHS ${AVFORMAT_INCLUDE_DIRS} + ${AVCODEC_INCLUDE_DIRS} + ${AVUTIL_INCLUDE_DIRS} + ${AVDEVICE_INCLUDE_DIRS} ) +endif( WIN32 ) + +# add in swscale if found +IF ( SWSCALE_FOUND ) + SET( FFMPEG_LIBRARY_DIR ${FFMPEG_LIBRARY_DIR} + ${SWSCALE_LIBRARY_DIRS} ) + SET( FFMPEG_INCLUDE_PATHS ${FFMPEG_INCLUDE_PATHS} + ${SWSCALE_INCLUDE_DIRS} ) + SET( FFMPEG_HEADERS ${FFMPEG_HEADERS} + ${FFMPEG_SWS_HEADERS} ) + SET( FFMPEG_PATH_SUFFIXES ${FFMPEG_PATH_SUFFIXES} + ${FFMPEG_SWS_PATH_SUFFIXES} ) + SET( FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} + ${FFMPEG_SWS_LIBRARIES} ) +ENDIF ( SWSCALE_FOUND ) + +# find includes +SET( INC_SUCCESS 0 ) +SET( TMP_ TMP-NOTFOUND ) +SET( FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_PATHS} ) +FOREACH( INC_ ${FFMPEG_HEADERS} ) + message( "checking: " ${INC_} ) + + FIND_PATH( TMP_ ${INC_} + PATHS ${FFMPEG_INCLUDE_PATHS} + PATH_SUFFIXES ${FFMPEG_PATH_SUFFIXES} ) + IF ( TMP_ ) + message( "found: " ${TMP_} ) + MATH( EXPR INC_SUCCESS ${INC_SUCCESS}+1 ) + SET( FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR} ${TMP_} ) + ENDIF ( TMP_ ) + SET( TMP_ TMP-NOTFOUND ) +ENDFOREACH( INC_ ) + +# clear out duplicates +#LIST( REMOVE_DUPLICATES FFMPEG_INCLUDE_DIR ) +#LIST( REMOVE_DUPLICATES FFMPEG_LIBRARY_DIR ) + +# find the full paths of the libraries +SET( TMP_ TMP-NOTFOUND ) +IF ( NOT WIN32 ) + FOREACH( LIB_ ${FFMPEG_LIBRARIES} ) + FIND_LIBRARY( TMP_ NAMES ${LIB_} PATHS ${FFMPEG_LIBRARY_DIR} ) + IF ( TMP_ ) + SET( FFMPEG_LIBRARIES_FULL ${FFMPEG_LIBRARIES_FULL} ${TMP_} ) + ENDIF ( TMP_ ) + SET( TMP_ TMP-NOTFOUND ) + ENDFOREACH( LIB_ ) + SET ( FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES_FULL} ) +ENDIF( NOT WIN32 ) + +LIST( LENGTH FFMPEG_HEADERS LIST_SIZE_ ) + +SET( FFMPEG_FOUND FALSE ) +SET( FFMPEG_SWSCALE_FOUND FALSE ) +IF ( ${INC_SUCCESS} EQUAL ${LIST_SIZE_} ) + SET( FFMPEG_FOUND TRUE ) + SET( FFMPEG_SWSCALE_FOUND ${SWSCALE_FOUND} ) +ENDIF ( ${INC_SUCCESS} EQUAL ${LIST_SIZE_} )