forked from Eyescale/CMake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindPoppler.cmake
178 lines (163 loc) · 6.23 KB
/
FindPoppler.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# - Try to find Poppler and specified components: {cpp, Qt4, Qt5}
# Once done this will define:
#
# POPPLER_FOUND - system has Poppler and specified components
# POPPLER_INCLUDE_DIRS - The include directories for Poppler headers
# POPPLER_LIBRARIES - Link these to use Poppler
# POPPLER_NEEDS_FONTCONFIG - A boolean indicating if libpoppler depends on libfontconfig
# POPPLER_HAS_XPDF - A boolean indicating if libpoppler headers are available
# POPPLER_INCLUDE_DIR - the include directory for libpoppler XPDF headers
#
# Redistribution and use of this file is allowed according to the terms of the
# MIT license. For details see the file COPYING-CMAKE-MODULES.
if( POPPLER_LIBRARIES )
# in cache already
set( Poppler_FIND_QUIETLY TRUE )
endif( POPPLER_LIBRARIES )
# Check which components we need to find
list(FIND Poppler_FIND_COMPONENTS "cpp" FIND_POS)
if(${FIND_POS} EQUAL -1)
set(FIND_CPP FALSE)
else()
set(FIND_CPP TRUE)
endif()
list(FIND Poppler_FIND_COMPONENTS "Qt4" FIND_POS)
if(${FIND_POS} EQUAL -1)
set(FIND_QT4 FALSE)
else()
set(FIND_QT4 TRUE)
endif()
list(FIND Poppler_FIND_COMPONENTS "Qt5" FIND_POS)
if(${FIND_POS} EQUAL -1)
set(FIND_QT5 FALSE)
else()
set(FIND_QT5 TRUE)
endif()
# Default values
set(POPPLER_FOUND FALSE)
set(POPPLER_INCLUDE_DIRS)
set(POPPLER_LIBRARIES)
set(POPPLER_REQUIRED "POPPLER_LIBRARY")
# use pkg-config to get the directories and then use these values
# in the find_path() and find_library() calls
if( NOT WIN32 )
find_package(PkgConfig)
pkg_check_modules(POPPLER_PKG QUIET poppler)
if( FIND_CPP )
pkg_check_modules(POPPLER_CPP_PKG QUIET poppler-cpp)
endif()
if( FIND_QT4 )
pkg_check_modules(POPPLER_QT4_PKG QUIET poppler-qt4)
endif()
if( FIND_QT5 )
pkg_check_modules(POPPLER_QT5_PKG QUIET poppler-qt5)
endif()
endif( NOT WIN32 )
# Check for Poppler headers (optional)
find_path( POPPLER_INCLUDE_DIR NAMES poppler-config.h PATH_SUFFIXES poppler )
if( NOT( POPPLER_INCLUDE_DIR ) )
if( NOT Poppler_FIND_QUIETLY )
message( STATUS "Could not find poppler-config.h, recompile Poppler with "
"ENABLE_XPDF_HEADERS to link against libpoppler directly." )
endif()
set( POPPLER_HAS_XPDF FALSE )
else()
set( POPPLER_HAS_XPDF TRUE )
list(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_INCLUDE_DIR})
endif()
# Find libpoppler (Required)
find_library( POPPLER_LIBRARY NAMES poppler ${POPPLER_CPP_PKG_LIBRARIES}
HINTS ${POPPLER_PKG_LIBDIR} ${POPPLER_CPP_PKG_LIBDIR} )
if( NOT(POPPLER_LIBRARY) )
if( NOT Poppler_FIND_QUIETLY )
message(STATUS "Could not find libpoppler." )
endif( NOT Poppler_FIND_QUIETLY )
else( NOT(POPPLER_LIBRARY) )
list(APPEND POPPLER_LIBRARIES ${POPPLER_LIBRARY})
# Scan poppler libraries for dependencies on Fontconfig
include(GetPrerequisites)
mark_as_advanced(gp_cmd)
GET_PREREQUISITES("${POPPLER_LIBRARY}" POPPLER_PREREQS 1 0 "" "")
if("${POPPLER_PREREQS}" MATCHES "fontconfig")
set(POPPLER_NEEDS_FONTCONFIG TRUE)
else()
set(POPPLER_NEEDS_FONTCONFIG FALSE)
endif()
# cpp Component
if( FIND_CPP )
list(APPEND POPPLER_REQUIRED POPPLER_CPP_INCLUDE_DIR POPPLER_CPP_LIBRARY)
find_path( POPPLER_CPP_INCLUDE_DIR NAMES poppler-version.h
HINTS ${POPPLER_PKG_INCLUDEDIR} ${POPPLER_CPP_PKG_INCLUDEDIR}
PATH_SUFFIXES cpp poppler/cpp )
if( NOT(POPPLER_CPP_INCLUDE_DIR) )
if( NOT Poppler_FIND_QUIETLY )
message(STATUS "Could not find Poppler cpp wrapper headers." )
endif( NOT Poppler_FIND_QUIETLY )
else()
list(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_CPP_INCLUDE_DIR})
endif()
find_library(
POPPLER_CPP_LIBRARY NAMES poppler-cpp ${POPPLER_CPP_PKG_LIBRARIES}
HINTS ${POPPLER_PKG_LIBDIR} ${POPPLER_CPP_PKG_LIBDIR} )
if( NOT(POPPLER_CPP_LIBRARY) )
if( NOT Poppler_FIND_QUIETLY )
message(STATUS "Could not find libpoppler-cpp." )
endif( NOT Poppler_FIND_QUIETLY )
else()
list(APPEND POPPLER_LIBRARIES ${POPPLER_CPP_LIBRARY})
endif()
endif()
# Qt4 Component
if( FIND_QT4 )
list(APPEND POPPLER_REQUIRED POPPLER_QT4_INCLUDE_DIR POPPLER_QT4_LIBRARY)
find_path(POPPLER_QT4_INCLUDE_DIR NAMES poppler-qt4.h poppler-link.h
HINTS ${POPPLER_PKG_INCLUDEDIR} ${POPPLER_CPP_QT4_INCLUDEDIR}
PATH_SUFFIXES qt4 poppler/qt4 )
if( NOT(POPPLER_QT4_INCLUDE_DIR) )
if( NOT Poppler_FIND_QUIETLY )
message(STATUS "Could not find Poppler-Qt4 headers." )
endif( NOT Poppler_FIND_QUIETLY )
else()
list(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_QT4_INCLUDE_DIR})
endif()
find_library(
POPPLER_QT4_LIBRARY NAMES poppler-qt4 ${POPPLER_QT4_PKG_LIBRARIES}
HINTS ${POPPLER_PKG_LIBDIR} ${POPPLER_QT4_PKG_LIBDIR} )
if( NOT(POPPLER_QT4_LIBRARY) )
if( NOT Poppler_FIND_QUIETLY )
message(STATUS "Could not find libpoppler-qt4." )
endif( NOT Poppler_FIND_QUIETLY )
else()
list(APPEND POPPLER_LIBRARIES ${POPPLER_QT4_LIBRARY})
endif()
endif()
# Qt5 Component
if( FIND_QT5 )
list(APPEND POPPLER_REQUIRED POPPLER_QT5_INCLUDE_DIR POPPLER_QT5_LIBRARY)
find_path(POPPLER_QT5_INCLUDE_DIR NAMES poppler-qt5.h poppler-link.h
HINTS ${POPPLER_QT5_INCLUDEDIR} ${POPPLER_QT5_PKG_INCLUDEDIR}
PATH_SUFFIXES qt5 poppler/qt5 )
if( NOT(POPPLER_QT5_INCLUDE_DIR) )
if( NOT Poppler_FIND_QUIETLY )
message( STATUS "Could not find Poppler-Qt5 headers." )
endif( NOT Poppler_FIND_QUIETLY )
else()
list(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_QT5_INCLUDE_DIR})
endif()
find_library(
POPPLER_QT5_LIBRARY NAMES poppler-qt5 ${POPPLER_QT5_PKG_LIBRARIES}
HINTS ${POPPLER_PKG_LIBDIR} ${POPPLER_QT5_PKG_LIBDIR} )
if( NOT(POPPLER_QT5_LIBRARY) )
if( NOT Poppler_FIND_QUIETLY )
message(STATUS "Could not find libpoppler-qt5." )
endif( NOT Poppler_FIND_QUIETLY )
else()
list(APPEND POPPLER_LIBRARIES ${POPPLER_QT5_LIBRARY})
endif()
endif()
endif( NOT(POPPLER_LIBRARY) )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Poppler DEFAULT_MSG ${POPPLER_REQUIRED})
mark_as_advanced(POPPLER_CPP_INCLUDE_DIR POPPLER_QT4_INCLUDE_DIR
POPPLER_QT5_INCLUDE_DIR POPPLER_LIBRARIES POPPLER_CPP_LIBRARY
POPPLER_QT4_LIBRARY POPPLER_QT5_LIBRARY)