Refactored the FFmpeg find script and the pdd CMakeLists.txt to improve the automatic detection of the required facilities

This commit is contained in:
Robert Osfield 2009-06-24 10:26:48 +00:00
parent 51579cf436
commit 5c0148106c
2 changed files with 76 additions and 44 deletions

View File

@ -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")

View File

@ -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 <cstdlib>
#include <poppler.h>
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()