From 5c0148106cd0d51823b305c488d3da8acd516675 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 24 Jun 2009 10:26:48 +0000 Subject: [PATCH] Refactored the FFmpeg find script and the pdd CMakeLists.txt to improve the automatic detection of the required facilities --- CMakeModules/FindFFmpeg.cmake | 83 +++++++++++++++++-------------- src/osgPlugins/pdf/CMakeLists.txt | 37 +++++++++++--- 2 files changed, 76 insertions(+), 44 deletions(-) diff --git a/CMakeModules/FindFFmpeg.cmake b/CMakeModules/FindFFmpeg.cmake index 134d86fd1..7a01ebcbe 100644 --- a/CMakeModules/FindFFmpeg.cmake +++ b/CMakeModules/FindFFmpeg.cmake @@ -26,6 +26,23 @@ MACRO(FFMPEG_FIND varname shortname headername) # 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/lib${shortname} + $ENV{FFMPEG_DIR}/include/lib${shortname} + ~/Library/Frameworks/lib${shortname} + /Library/Frameworks/lib${shortname} + /usr/local/include/lib${shortname} + /usr/include/lib${shortname} + /sw/include/lib${shortname} # Fink + /opt/local/include/lib${shortname} # DarwinPorts + /opt/csw/include/lib${shortname} # Blastwave + /opt/include/lib${shortname} + /usr/freeware/include/lib${shortname} + PATH_SUFFIXES ffmpeg + DOC "Location of FFMPEG Headers" + ) + FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername} PATHS ${FFMPEG_ROOT}/include @@ -43,26 +60,6 @@ MACRO(FFMPEG_FIND varname shortname headername) DOC "Location of FFMPEG Headers" ) - # 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 - $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 Headers" - ) - ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS) - FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES NAMES ${shortname} PATHS @@ -91,22 +88,34 @@ 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" -) +IF(WIN32) + + 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" + ) + + IF (FFMPEG_STDINT_INCLUDE_DIR) + SET(STDINT_OK TRUE) + ENDIF() + +ELSE() + + # SET(STDINT_OK TRUE) + +ENDIF() FFMPEG_FIND(LIBAVFORMAT avformat avformat.h) FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h) @@ -116,7 +125,7 @@ FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look SET(FFMPEG_FOUND "NO") # Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional. -IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND FFMPEG_STDINT_INCLUDE_DIR) +IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND STDINT_OK) SET(FFMPEG_FOUND "YES") diff --git a/src/osgPlugins/pdf/CMakeLists.txt b/src/osgPlugins/pdf/CMakeLists.txt index c27dc345e..4d9a3a22a 100644 --- a/src/osgPlugins/pdf/CMakeLists.txt +++ b/src/osgPlugins/pdf/CMakeLists.txt @@ -1,10 +1,33 @@ -SET(TARGET_SRC ReaderWriterPDF.cpp ) +INCLUDE(CheckCXXSourceRuns) -INCLUDE_DIRECTORIES( ${CAIRO_INCLUDE_DIRS} ${POPPLER_INCLUDE_DIRS} ) -LINK_DIRECTORIES(${CAIRO_LIBRARY_DIRS} ${POPPLER_LIBRARY_DIRS}) -SET(TARGET_EXTERNAL_LIBRARIES ${CAIRO_LIBRARIES} ${POPPLER_LIBRARIES} ) +SET(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIRS}) -SET(TARGET_ADDED_LIBRARIES osgWidget) +# Do step by step checking, +CHECK_CXX_SOURCE_RUNS(" +#include +#include +int main() +{ +#ifdef POPPLER_HAS_CAIRO + return EXIT_SUCCESS; +#else + return EXIT_FAILURE +#endif +} +" POPPLER_HAS_CAIRO) -#### end var setup ### -SETUP_PLUGIN(pdf pdf) + +IF (POPPLER_HAS_CAIRO) + + SET(TARGET_SRC ReaderWriterPDF.cpp ) + + INCLUDE_DIRECTORIES( ${CAIRO_INCLUDE_DIRS} ${POPPLER_INCLUDE_DIRS} ) + LINK_DIRECTORIES(${CAIRO_LIBRARY_DIRS} ${POPPLER_LIBRARY_DIRS}) + SET(TARGET_EXTERNAL_LIBRARIES ${CAIRO_LIBRARIES} ${POPPLER_LIBRARIES} ) + + SET(TARGET_ADDED_LIBRARIES osgWidget) + + #### end var setup ### + SETUP_PLUGIN(pdf pdf) + +ENDIF()