1 # - Try to find the poppler PDF library
2 # Once done this will define
4 # POPPLER_FOUND - system has poppler
5 # POPPLER_INCLUDE_DIR - the poppler include directory
6 # POPPLER_LIBRARY - Link this to use poppler
9 # Copyright (c) 2006-2007, Pino Toscano, <pino@kde.org>
11 # Redistribution and use is allowed according to the terms of the BSD license.
12 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 if(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)
17 set(POPPLER_FOUND TRUE)
19 else(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)
21 # use pkg-config to get the directories and then use these values
22 # in the FIND_PATH() and FIND_LIBRARY() calls
25 PKGCONFIG(poppler-qt4 _PopplerIncDir _PopplerLinkDir _PopplerLinkFlags _PopplerCflags)
29 # query pkg-config asking for a poppler-qt4 >= 0.5.4
30 EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=0.5.4 poppler-qt4 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
31 if(_return_VALUE STREQUAL "0")
32 set(POPPLER_FOUND TRUE)
33 endif(_return_VALUE STREQUAL "0")
34 else(_PopplerLinkFlags)
35 # try to find poppler without pkgconfig
36 find_library( LIBPOPPLER poppler )
37 find_library( LIBPOPPLER_QT4 poppler-qt4 )
38 find_path( INCLUDEPOPPLER_QT4 poppler/qt4/poppler-qt4.h )
39 find_path( INCLUDEPOPPLER poppler-qt4.h PATHS ${INCLUDEPOPPLER_QT4}/poppler/qt4 )
40 if( LIBPOPPLER_QT4 AND LIBPOPPLER AND INCLUDEPOPPLER )
41 set( POPPLER_FOUND TRUE )
42 set(_PopplerLinkFlags ${LIBPOPPLER} ${LIBPOPPLER_QT4})
43 set(POPPLER_INCLUDE_DIR ${INCLUDEPOPPLER})
44 endif( LIBPOPPLER_QT4 AND LIBPOPPLER AND INCLUDEPOPPLER )
45 endif(_PopplerLinkFlags)
48 set(POPPLER_LIBRARY ${_PopplerLinkFlags})
50 # the cflags for poppler-qt4 can contain more than one include path
51 separate_arguments(_PopplerCflags)
52 foreach(_includedir ${_PopplerCflags})
53 string(REGEX REPLACE "-I(.+)" "\\1" _includedir "${_includedir}")
54 set(POPPLER_INCLUDE_DIR ${POPPLER_INCLUDE_DIR} ${_includedir})
55 endforeach(_includedir)
57 # check whether we're using poppler 0.6
58 set(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIR} ${QT_INCLUDE_DIR})
59 set(CMAKE_REQUIRED_LIBRARIES ${POPPLER_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY})
60 check_cxx_source_compiles("
61 #include <poppler-qt4.h>
65 Poppler::SoundObject * so = 0;
71 set(CMAKE_REQUIRED_INCLUDES)
72 set(CMAKE_REQUIRED_LIBRARIES)
74 set(poppler06Message "yes")
75 else (HAVE_POPPLER_0_6)
76 set(poppler06Message "no")
77 endif (HAVE_POPPLER_0_6)
78 if (NOT Poppler_FIND_QUIETLY)
79 message(STATUS "Found Poppler-Qt4: ${POPPLER_LIBRARY}, 0.6.x? ${poppler06Message}")
80 endif (NOT Poppler_FIND_QUIETLY)
82 if (Poppler_FIND_REQUIRED)
83 message(FATAL_ERROR "Could NOT find Poppler-Qt4")
84 endif (Poppler_FIND_REQUIRED)
85 message(STATUS "Could not find OPTIONAL package Poppler-Qt4")
88 # ensure that they are cached
89 set(POPPLER_INCLUDE_DIR ${POPPLER_INCLUDE_DIR} CACHE INTERNAL "The Poppler-Qt4 include path")
90 set(POPPLER_LIBRARY ${POPPLER_LIBRARY} CACHE INTERNAL "The Poppler-Qt4 library")
91 set(HAVE_POPPLER_0_6 ${HAVE_POPPLER_0_6} CACHE INTERNAL "Whether the version of Poppler-Qt4 is 0.6")
93 endif(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)