From 51964a2b79191c9b8dfe7553447b035d8e3b8a25 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 23 Mar 2009 15:48:19 +0000 Subject: [PATCH] From David Callu, clean up of FindFFmpeg include paths --- CMakeModules/FindFFmpeg.cmake | 53 +++++++++++++--------------- src/osgPlugins/ffmpeg/CMakeLists.txt | 37 ++++++++----------- 2 files changed, 39 insertions(+), 51 deletions(-) diff --git a/CMakeModules/FindFFmpeg.cmake b/CMakeModules/FindFFmpeg.cmake index 3a97a0393..eabe5a0b8 100644 --- a/CMakeModules/FindFFmpeg.cmake +++ b/CMakeModules/FindFFmpeg.cmake @@ -9,12 +9,25 @@ # # Created by Robert Osfield. + +#In ffmpeg code, old version use "#include " and newer use "#include " +#In OSG ffmpeg plugin, we use "#include " for compatibility with old version of ffmpeg + +#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) + +#Then we need to include ${FFMPEG_libname_INCLUDE_DIRS} (in old version case, use by ffmpeg header and osg plugin code) +# (in new version case, use by ffmpeg header) +#and ${FFMPEG_libname_INCLUDE_DIRS/libname} (in new version case, use by osg plugin code) + + # Macro to find header and lib directories # example: FFMPEG_FIND(AVFORMAT avformat avformat.h) - MACRO(FFMPEG_FIND varname shortname headername) - # First try to find header directly in include directory + # old version of ffmpeg put header in $prefix/include/[ffmpeg] + # so try to find header in include directory FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername} + PATHS ${FFMPEG_ROOT}/include $ENV{FFMPEG_DIR}/include $ENV{OSGDIR}/include @@ -22,17 +35,18 @@ MACRO(FFMPEG_FIND varname shortname headername) ~/Library/Frameworks /Library/Frameworks /usr/local/include - /usr/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 Headers" ) - # If not found, try to find it in a subdirectory. Tanguy's build has - # avformat.h in include/libavformat, so this catches that case. If that's - # standard, perhaps we can keep just this case. + # newer version of ffmpeg put header in $prefix/include/[ffmpeg/]lib${shortname} + # so try to find lib${shortname}/header in include directory IF(NOT FFMPEG_${varname}_INCLUDE_DIRS) FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername} ${FFMPEG_ROOT}/include @@ -48,28 +62,8 @@ MACRO(FFMPEG_FIND varname shortname headername) /opt/csw/include # Blastwave /opt/include /usr/freeware/include - ) - ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS) - - - # If not found, try to find it in a subdirectory. Tanguy's build has - # avformat.h in include/libavformat, so this catches that case. If that's - # standard, perhaps we can keep just this case. - IF(NOT FFMPEG_${varname}_INCLUDE_DIRS) - FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ffmpeg/${headername} - ${FFMPEG_ROOT}/include - $ENV{FFMPEG_DIR}/include - $ENV{OSGDIR}/include - $ENV{OSG_ROOT}/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 Headers" ) ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS) @@ -91,9 +85,10 @@ MACRO(FFMPEG_FIND varname shortname headername) /opt/csw/lib /opt/lib /usr/freeware/lib64 + DOC "Location of FFMPEG Libraries" ) - IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) + IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) SET(FFMPEG_${varname}_FOUND 1) ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) diff --git a/src/osgPlugins/ffmpeg/CMakeLists.txt b/src/osgPlugins/ffmpeg/CMakeLists.txt index 577b5afdf..7a10b6e3e 100644 --- a/src/osgPlugins/ffmpeg/CMakeLists.txt +++ b/src/osgPlugins/ffmpeg/CMakeLists.txt @@ -1,34 +1,27 @@ # INCLUDE_DIRECTORIES( ${FFMPEG_INCLUDE_DIRS} ) + +INCLUDE_DIRECTORIES( + ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat + ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice + ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec + ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavcodec +) + +LINK_DIRECTORIES(${FFMPEG_LIBRARY_DIRS}) + +SET(TARGET_EXTERNAL_LIBRARIES ${FFMPEG_LIBRARIES} ) + + + IF (FFMPEG_LIBSWSCALE_FOUND) - INCLUDE_DIRECTORIES( - ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/ffmpeg - ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/ffmpeg - ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/ffmpeg - ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavcodec ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/ffmpeg - ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS} ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS}/libswscale ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS}/ffmpeg - ) + INCLUDE_DIRECTORIES( ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS} ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS}/libswscale ) ADD_DEFINITIONS(-DUSE_SWSCALE) - LINK_DIRECTORIES(${FFMPEG_LIBRARY_DIRS}) - SET(TARGET_EXTERNAL_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_LIBSWSCALE_LIBRARIES}) -ELSE(FFMPEG_LIBSWSCALE_FOUND) - - INCLUDE_DIRECTORIES( - ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/ffmpeg - ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/ffmpeg - ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/ffmpeg - ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavcodec ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/ffmpeg - ) - - LINK_DIRECTORIES(${FFMPEG_LIBRARY_DIRS}) - - SET(TARGET_EXTERNAL_LIBRARIES ${FFMPEG_LIBRARIES} ) - ENDIF() # MESSAGE("FFMPEG_LIBAVFORMAT_INCLUDE_DIRS = " ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} )