1 | #========================================================================
|
---|
2 | #
|
---|
3 | # xpdf/cmake-xpdf.txt
|
---|
4 | #
|
---|
5 | # CMake script for the Xpdf tools.
|
---|
6 | #
|
---|
7 | # Copyright 2015 Glyph & Cog, LLC
|
---|
8 | #
|
---|
9 | #========================================================================
|
---|
10 |
|
---|
11 | include_directories("${PROJECT_SOURCE_DIR}")
|
---|
12 | include_directories("${PROJECT_BINARY_DIR}")
|
---|
13 | include_directories("${PROJECT_SOURCE_DIR}/goo")
|
---|
14 | include_directories("${PROJECT_SOURCE_DIR}/fofi")
|
---|
15 | include_directories("${PROJECT_SOURCE_DIR}/splash")
|
---|
16 |
|
---|
17 | #------------------
|
---|
18 | ## https://stackoverflow.com/questions/36220123/undefined-reference-to-png-set-longjmp-fn-when-compiling-pcl-source-file
|
---|
19 | ## https://stackoverflow.com/questions/30980383/cmake-compile-options-for-libpng
|
---|
20 |
|
---|
21 | # search for pkg-config
|
---|
22 | include (FindPkgConfig)
|
---|
23 | if (NOT PKG_CONFIG_FOUND)
|
---|
24 | message (FATAL_ERROR "pkg-config not found")
|
---|
25 | endif ()
|
---|
26 |
|
---|
27 | # check for libpng
|
---|
28 | pkg_check_modules (PNG libpng15 REQUIRED)
|
---|
29 | if (NOT PNG_FOUND)
|
---|
30 | message(FATAL_ERROR "You don't seem to have libpng15 development libraries installed")
|
---|
31 | else ()
|
---|
32 | include_directories (${PNG_INCLUDE_DIRS})
|
---|
33 | link_directories (${PNG_LIBRARY_DIRS})
|
---|
34 | link_libraries (${PNG_LIBRARIES})
|
---|
35 | endif ()
|
---|
36 | #------------------
|
---|
37 |
|
---|
38 | if (ZLIB_FOUND)
|
---|
39 | message(STATUS "@@@@@@@@@@@@@@@ ZLIB_FOUND ${ZLIB_LIBRARIES}")
|
---|
40 | include_directories("${ZLIB_INCLUDE_DIRS}")
|
---|
41 | else ()
|
---|
42 | message(STATUS "@@@@@@@@@@@@@@@ NOT ZLIB_FOUND")
|
---|
43 | endif ()
|
---|
44 | if (PNG_FOUND)
|
---|
45 | message(STATUS "@@@@@@@@@@@@@@@ PNG_FOUND ${PNG_LINK_FLAGS}")
|
---|
46 | include_directories("${PNG_INCLUDE_DIRS}")
|
---|
47 | link_directories (${PNG_LIBRARY_DIRS})
|
---|
48 | link_libraries (${PNG_LIBRARIES})
|
---|
49 | add_definitions("${PNG_DEFINITIONS}")
|
---|
50 | else ()
|
---|
51 | message(STATUS "@@@@@@@@@@@@@@@ NOT PNG_FOUND")
|
---|
52 | endif ()
|
---|
53 | if (HAVE_LCMS)
|
---|
54 | include_directories("${LCMS_INCLUDE_DIR}")
|
---|
55 | set(COLOR_MANAGER_SOURCE "ColorManager.cc")
|
---|
56 | else ()
|
---|
57 | set(COLOR_MANAGER_SOURCE "")
|
---|
58 | endif ()
|
---|
59 |
|
---|
60 | add_library(xpdf_objs OBJECT
|
---|
61 | AcroForm.cc
|
---|
62 | Annot.cc
|
---|
63 | Array.cc
|
---|
64 | BuiltinFont.cc
|
---|
65 | BuiltinFontTables.cc
|
---|
66 | Catalog.cc
|
---|
67 | CharCodeToUnicode.cc
|
---|
68 | CMap.cc
|
---|
69 | ${COLOR_MANAGER_SOURCE}
|
---|
70 | Decrypt.cc
|
---|
71 | Dict.cc
|
---|
72 | Error.cc
|
---|
73 | FontEncodingTables.cc
|
---|
74 | Form.cc
|
---|
75 | Function.cc
|
---|
76 | Gfx.cc
|
---|
77 | GfxFont.cc
|
---|
78 | GfxState.cc
|
---|
79 | GlobalParams.cc
|
---|
80 | JArithmeticDecoder.cc
|
---|
81 | JBIG2Stream.cc
|
---|
82 | JPXStream.cc
|
---|
83 | Lexer.cc
|
---|
84 | Link.cc
|
---|
85 | NameToCharCode.cc
|
---|
86 | Object.cc
|
---|
87 | OptionalContent.cc
|
---|
88 | Outline.cc
|
---|
89 | OutputDev.cc
|
---|
90 | Page.cc
|
---|
91 | Parser.cc
|
---|
92 | PDFDoc.cc
|
---|
93 | PDFDocEncoding.cc
|
---|
94 | PSTokenizer.cc
|
---|
95 | SecurityHandler.cc
|
---|
96 | Stream.cc
|
---|
97 | TextString.cc
|
---|
98 | UnicodeMap.cc
|
---|
99 | UnicodeTypeTable.cc
|
---|
100 | UTF8.cc
|
---|
101 | XFAForm.cc
|
---|
102 | XRef.cc
|
---|
103 | Zoox.cc
|
---|
104 | )
|
---|
105 |
|
---|
106 | #--- object files needed by XpdfWidget
|
---|
107 |
|
---|
108 | if ((QT4_FOUND OR Qt5Widgets_FOUND)
|
---|
109 | AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
|
---|
110 |
|
---|
111 | if (HIGHLIGHTED_REGIONS)
|
---|
112 | set(HIGHLIGHT_SRC "HighlightFile.cc")
|
---|
113 | else ()
|
---|
114 | set(HIGHLIGHT_SRC "")
|
---|
115 | endif ()
|
---|
116 |
|
---|
117 | add_library(xpdf_widget_objs OBJECT
|
---|
118 | DisplayState.cc
|
---|
119 | PDFCore.cc
|
---|
120 | PreScanOutputDev.cc
|
---|
121 | PSOutputDev.cc
|
---|
122 | SplashOutputDev.cc
|
---|
123 | TextOutputDev.cc
|
---|
124 | TileCache.cc
|
---|
125 | TileCompositor.cc
|
---|
126 | TileMap.cc
|
---|
127 | ${HIGHLIGHT_SRC}
|
---|
128 | )
|
---|
129 | endif ()
|
---|
130 |
|
---|
131 | # We want to build static xpdf-tools binaries. See
|
---|
132 | # https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake
|
---|
133 | # Want to make the min number of changes for building statically, so using this way:
|
---|
134 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
---|
135 | SET(BUILD_SHARED_LIBS OFF)
|
---|
136 | SET(CMAKE_EXE_LINKER_FLAGS "-static")
|
---|
137 | # See https://github.com/droe/sslsplit/issues/82
|
---|
138 | # for warnings of this nature:
|
---|
139 | # ../goo/libgoo.a(gfile.cc.o): In function `getHomeDir()':
|
---|
140 | # gfile.cc:(.text+0x55): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
|
---|
141 | # gfile.cc:(.text+0x90): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
|
---|
142 | # See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
|
---|
143 | # after googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:
|
---|
144 | # undefined reference to `pthread_mutex_unlock'
|
---|
145 | set(THREADS_PREFER_PTHREAD_FLAG ON)
|
---|
146 | find_package(Threads REQUIRED)
|
---|
147 |
|
---|
148 | #-- libpng
|
---|
149 | # https://stackoverflow.com/questions/36220123/undefined-reference-to-png-set-longjmp-fn-when-compiling-pcl-source-file
|
---|
150 | # https://stackoverflow.com/questions/30980383/cmake-compile-options-for-libpng
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 | #--- pdftops
|
---|
155 |
|
---|
156 | if (HAVE_SPLASH)
|
---|
157 | add_executable(pdftops
|
---|
158 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
159 | PreScanOutputDev.cc
|
---|
160 | PSOutputDev.cc
|
---|
161 | SplashOutputDev.cc
|
---|
162 | pdftops.cc
|
---|
163 | )
|
---|
164 | target_link_libraries(pdftops goo fofi splash
|
---|
165 | ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
166 | ${DTYPE_LIBRARY}
|
---|
167 | ${LCMS_LIBRARY}
|
---|
168 | Threads::Threads)
|
---|
169 | else ()
|
---|
170 | add_executable(pdftops
|
---|
171 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
172 | PreScanOutputDev.cc
|
---|
173 | PSOutputDev.cc
|
---|
174 | pdftops.cc
|
---|
175 | )
|
---|
176 | target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
177 | endif ()
|
---|
178 | install(TARGETS pdftops RUNTIME DESTINATION bin)
|
---|
179 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
|
---|
180 |
|
---|
181 | #--- pdftotext
|
---|
182 |
|
---|
183 | add_executable(pdftotext
|
---|
184 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
185 | TextOutputDev.cc
|
---|
186 | pdftotext.cc
|
---|
187 | )
|
---|
188 | target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} ${PNG_LIBRARIES} ${PNG_LINK_FLAGS} Threads::Threads)
|
---|
189 | install(TARGETS pdftotext RUNTIME DESTINATION bin)
|
---|
190 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
|
---|
191 |
|
---|
192 | #--- pdftohtml
|
---|
193 |
|
---|
194 | if (HAVE_SPLASH AND PNG_FOUND)
|
---|
195 | add_executable(pdftohtml
|
---|
196 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
197 | HTMLGen.cc
|
---|
198 | SplashOutputDev.cc
|
---|
199 | TextOutputDev.cc
|
---|
200 | pdftohtml.cc
|
---|
201 | )
|
---|
202 | target_link_libraries(pdftohtml goo fofi splash
|
---|
203 | ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
204 | ${DTYPE_LIBRARY}
|
---|
205 | ${LCMS_LIBRARY} ${PNG_LIBRARIES}
|
---|
206 | Threads::Threads)
|
---|
207 | install(TARGETS pdftohtml RUNTIME DESTINATION bin)
|
---|
208 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
|
---|
209 | endif ()
|
---|
210 |
|
---|
211 | #--- pdfinfo
|
---|
212 |
|
---|
213 | add_executable(pdfinfo
|
---|
214 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
215 | pdfinfo.cc
|
---|
216 | )
|
---|
217 | target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
218 | install(TARGETS pdfinfo RUNTIME DESTINATION bin)
|
---|
219 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
|
---|
220 |
|
---|
221 | #--- pdffonts
|
---|
222 |
|
---|
223 | add_executable(pdffonts
|
---|
224 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
225 | pdffonts.cc
|
---|
226 | )
|
---|
227 | target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
228 | install(TARGETS pdffonts RUNTIME DESTINATION bin)
|
---|
229 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
|
---|
230 |
|
---|
231 | #--- pdfdetach
|
---|
232 |
|
---|
233 | add_executable(pdfdetach
|
---|
234 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
235 | pdfdetach.cc
|
---|
236 | )
|
---|
237 | target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
238 | install(TARGETS pdfdetach RUNTIME DESTINATION bin)
|
---|
239 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
|
---|
240 |
|
---|
241 | #--- pdftoppm
|
---|
242 |
|
---|
243 | if (HAVE_SPLASH)
|
---|
244 | add_executable(pdftoppm
|
---|
245 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
246 | SplashOutputDev.cc
|
---|
247 | pdftoppm.cc
|
---|
248 | )
|
---|
249 | target_link_libraries(pdftoppm goo fofi splash
|
---|
250 | ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
251 | ${DTYPE_LIBRARY}
|
---|
252 | ${LCMS_LIBRARY}
|
---|
253 | Threads::Threads)
|
---|
254 | install(TARGETS pdftoppm RUNTIME DESTINATION bin)
|
---|
255 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
|
---|
256 | endif ()
|
---|
257 |
|
---|
258 | #--- pdftopng
|
---|
259 |
|
---|
260 | if (HAVE_SPLASH AND PNG_FOUND)
|
---|
261 | add_executable(pdftopng
|
---|
262 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
263 | SplashOutputDev.cc
|
---|
264 | pdftopng.cc
|
---|
265 | )
|
---|
266 | target_link_libraries(pdftopng goo fofi splash
|
---|
267 | ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
268 | ${DTYPE_LIBRARY}
|
---|
269 | ${LCMS_LIBRARY} ${PNG_LIBRARIES} Threads::Threads)
|
---|
270 | install(TARGETS pdftopng RUNTIME DESTINATION bin)
|
---|
271 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
|
---|
272 | endif ()
|
---|
273 |
|
---|
274 | #--- pdfimages
|
---|
275 |
|
---|
276 | add_executable(pdfimages
|
---|
277 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
278 | ImageOutputDev.cc
|
---|
279 | pdfimages.cc
|
---|
280 | )
|
---|
281 | target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
282 | install(TARGETS pdfimages RUNTIME DESTINATION bin)
|
---|
283 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
|
---|
284 |
|
---|
285 | #--- xpdfrc man page
|
---|
286 |
|
---|
287 | install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
|
---|