Changeset 9863

Show
Ignore:
Timestamp:
03/04/09 17:16:07 (5 years ago)
Author:
robert
Message:

From Jean-Sebastien Guay, added non pkg-config based ffmpeg search scheme.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/CMakeModules/FindFFmpeg.cmake

    r9854 r9863  
    22# This module defines 
    33# FFMPEG_LIBRARIES 
    4 # FFMPEG_FOUND, if false, do not try to link to ffmpeg  
     4# FFMPEG_FOUND, if false, do not try to link to ffmpeg 
    55# FFMPEG_INCLUDE_DIR, where to find the headers 
    66# 
     
    88# correspond to the ./configure --prefix=$FFMPEG_DIR 
    99# 
    10 # Created by Robert Osfield.  
     10# Created by Robert Osfield. 
    1111 
    12 #use pkg-config to find various modes 
    13 INCLUDE(FindPkgConfig OPTIONAL) 
     12# Macro to find header and lib directories 
     13# example: FFMPEG_FIND(AVFORMAT avformat avformat.h) 
     14MACRO(FFMPEG_FIND varname shortname headername) 
     15    # First try to find header directly in include directory 
     16    FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername} 
     17        ${FFMPEG_ROOT}/include 
     18        $ENV{FFMPEG_DIR}/include 
     19        $ENV{OSGDIR}/include 
     20        $ENV{OSG_ROOT}/include 
     21        ~/Library/Frameworks 
     22        /Library/Frameworks 
     23        /usr/local/include 
     24        /usr/include/ 
     25        /sw/include # Fink 
     26        /opt/local/include # DarwinPorts 
     27        /opt/csw/include # Blastwave 
     28        /opt/include 
     29        /usr/freeware/include 
     30    ) 
    1431 
    15 IF(PKG_CONFIG_FOUND) 
     32    # If not found, try to find it in a subdirectory. Tanguy's build has 
     33    # avformat.h in include/libavformat, so this catches that case. If that's 
     34    # standard, perhaps we can keep just this case. 
     35    IF(NOT FFMPEG_${varname}_INCLUDE_DIRS) 
     36        FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername} 
     37            ${FFMPEG_ROOT}/include 
     38            $ENV{FFMPEG_DIR}/include 
     39            $ENV{OSGDIR}/include 
     40            $ENV{OSG_ROOT}/include 
     41            ~/Library/Frameworks 
     42            /Library/Frameworks 
     43            /usr/local/include 
     44            /usr/include/ 
     45            /sw/include # Fink 
     46            /opt/local/include # DarwinPorts 
     47            /opt/csw/include # Blastwave 
     48            /opt/include 
     49            /usr/freeware/include 
     50        ) 
     51    ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS) 
    1652 
    17     INCLUDE(FindPkgConfig) 
     53    FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES 
     54        NAMES ${shortname} 
     55        PATHS 
     56        ${FFMPEG_ROOT}/lib 
     57        $ENV{FFMPEG_DIR}/lib 
     58        $ENV{OSGDIR}/lib 
     59        $ENV{OSG_ROOT}/lib 
     60        ~/Library/Frameworks 
     61        /Library/Frameworks 
     62        /usr/local/lib 
     63        /usr/local/lib64 
     64        /usr/lib 
     65        /usr/lib64 
     66        /sw/lib 
     67        /opt/local/lib 
     68        /opt/csw/lib 
     69        /opt/lib 
     70        /usr/freeware/lib64 
     71    ) 
    1872 
    19     pkg_check_modules(FFMPEG_LIBAVFORMAT libavformat) 
    20     pkg_check_modules(FFMPEG_LIBAVDEVICE libavdevice) 
    21     pkg_check_modules(FFMPEG_LIBAVCODEC libavcodec) 
    22     pkg_check_modules(FFMPEG_LIBAVUTIL libavutil) 
    23     pkg_check_modules(FFMPEG_LIBSWSCALE libswscale) 
     73    IF   (FFMPEG_${varname}_LIBRARIES) 
     74        SET(FFMPEG_${varname}_FOUND 1) 
     75    ENDIF(FFMPEG_${varname}_LIBRARIES) 
    2476 
    25 ENDIF(PKG_CONFIG_FOUND) 
     77ENDMACRO(FFMPEG_FIND) 
     78 
     79SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG") 
     80 
     81FFMPEG_FIND(LIBAVFORMAT avformat avformat.h) 
     82FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h) 
     83FFMPEG_FIND(LIBAVCODEC  avcodec  avcodec.h) 
     84FFMPEG_FIND(LIBAVUTIL   avutil   avutil.h) 
     85FFMPEG_FIND(LIBSWSCALE  swscale  swscale.h)  # not sure about the header to look for here. 
    2686 
    2787SET(FFMPEG_FOUND "NO") 
     88# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional. 
    2889IF   (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) 
    29     
     90 
    3091    SET(FFMPEG_FOUND "YES") 
    3192 
     
    3495    SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS}) 
    3596 
     97    # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later. 
    3698    SET(FFMPEG_LIBRARIES 
    3799        ${FFMPEG_LIBAVFORMAT_LIBRARIES} 
     
    39101        ${FFMPEG_LIBAVCODEC_LIBRARIES} 
    40102        ${FFMPEG_LIBAVUTIL_LIBRARIES}) 
    41     
     103 
     104ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) 
     105 
     106    MESSAGE(STATUS "Could not find FFMPEG") 
     107 
    42108ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND) 
    43  
    44