source: gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt@ 32249

Last change on this file since 32249 was 32249, checked in by ak19, 6 years ago

All the changes to incorporate libtiff and libjpeg into the xpdftools GS2 extension, to get libjpeg compiled up on 64 bit machines, and for both libs to be seen and used by xpdftools when this is built.

File size: 10.9 KB
Line 
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#========================================================================
12# This is a customised version of Xpdf Tools' CMake file for Greenstone
13# where we want to build static xpdf-tools executables.
14# Refer to the GS-README.txt file for the Greenstone "xpdf-tools"
15# gs2-extension and read section D for the GS specific customisations
16# in this file and the reasoning behind them, most of which have to do
17# with attempting to successfully build xpdf-tools statically.
18#========================================================================
19
20include_directories("${PROJECT_SOURCE_DIR}")
21include_directories("${PROJECT_BINARY_DIR}")
22include_directories("${PROJECT_SOURCE_DIR}/goo")
23include_directories("${PROJECT_SOURCE_DIR}/fofi")
24include_directories("${PROJECT_SOURCE_DIR}/splash")
25
26
27# When compiling statically, XPDFTOOLS.sh will have set the custom
28# GSDLFLAG_STATIC flag to either "-static" for linux or "-Bstatic" for darwin
29
30if(GSDLFLAG_STATIC)
31 message(STATUS "@@@@ GSDLFLAG_STATIC SET to ${GSDLFLAG_STATIC}. Building xpdf-tools statically.")
32else ()
33 message(STATUS "@@@@ GSDLFLAG_STATIC not SET. Building dynamically using xpdf-tools' (mostly) original, unmodified linker flags.")
34endif ()
35if (JPEG_FOUND)
36 include_directories("${JPEG_INCLUDE_DIR}")
37 add_definitions("${JPEG_DEFINITIONS}")
38 message(STATUS "@@@@@@@@@@@@@@@ JPEG_FOUND (include_dir ; include_dirs): ${JPEG_INCLUDE_DIR} ; ${JPEG_INCLUDE_DIRS}")
39else ()
40 message(STATUS "@@@@@@@@@@@@@@@ NO JPEG_FOUND")
41endif ()
42if (TIFF_FOUND)
43 include_directories("${TIFF_INCLUDE_DIRS}")
44 add_definitions("${TIFF_DEFINITIONS}")
45 message(STATUS "@@@@@@@@@@@@@@@ TIFF_FOUND ${TIFF_INCLUDE_DIRS}")
46else ()
47 message(STATUS "@@@@@@@@@@@@@@@ NO TIFF_FOUND")
48endif ()
49if (PNG_FOUND)
50 include_directories("${PNG_INCLUDE_DIRS}")
51 add_definitions("${PNG_DEFINITIONS}")
52else ()
53 message(STATUS "@@@@@@@@@@@@@@@ NO PNG_FOUND")
54endif ()
55# https://stackoverflow.com/questions/36126333/mingw-cmake-undefined-reference-to-zlib
56if (ZLIB_FOUND)
57 include_directories("${ZLIB_INCLUDE_DIRS}")
58 add_definitions("${ZLIB_DEFINITIONS}")
59else ()
60 message(STATUS "@@@@@@@@@@@@@@@ NO ZLIB_FOUND")
61endif ()
62if (HAVE_LCMS)
63 include_directories("${LCMS_INCLUDE_DIR}")
64 set(COLOR_MANAGER_SOURCE "ColorManager.cc")
65 if(GSDLFLAG_STATIC)
66 # Untested combination, warn https://cmake.org/cmake/help/v3.0/command/message.html
67 message(AUTHOR_WARNING "@@@@@@@@@@@@@@@ GSDL Warning: static building with HAVE_LCMS on. If running ldd/file on generated binaries shows any binary to be partially a dynamic executable, then Export VERBOSE=1 and re-run the CMake build. Then check the verbose build output's linker flags (for static building) for that binary: they should not be -Wl,-Bstatic LIBS -Wl,-Bdynamic -lpthread but -static LIBS. Fix it by removing all references to LCMS_LIBRARY in the static linking flags of target_link_libraries statements (i.e. when GSDLFLAG_STATIC is set) in file gs-CMakeLists.txt and replacing them with the -l equivalent for the color manager library, (l)cms. @@@@@@@@@@@@@@@")
68 endif ()
69else ()
70 set(COLOR_MANAGER_SOURCE "")
71endif ()
72if (DTYPE_LIBRARY)
73 if(GSDLFLAG_STATIC)
74 # Untested combination, warn
75 message(AUTHOR_WARNING "@@@@@@@@@@@@@@@ GSDL Warning: static building with TYPE_LIBRARY. If running ldd/file on generated binaries shows any binary to be partially a dynamic executable, then export VERBOSE=1 and re-run the CMake build. Then check the verbose build output's linker flags (for static building) for that binary: they should not be -Wl,-Bstatic LIBS -Wl,-Bdynamic -lpthread but -static LIBS. Fix it by removing all references to DTYPE_LIBRARY in the static linking flags of target_link_libraries statements (i.e. when GSDLFLAG_STATIC is set) in file gs-CMakeLists.txt and replacing them with the -l equivalent for typelib. @@@@@@@@@@@@@@@")
76 endif ()
77endif ()
78add_library(xpdf_objs OBJECT
79 AcroForm.cc
80 Annot.cc
81 Array.cc
82 BuiltinFont.cc
83 BuiltinFontTables.cc
84 Catalog.cc
85 CharCodeToUnicode.cc
86 CMap.cc
87 ${COLOR_MANAGER_SOURCE}
88 Decrypt.cc
89 Dict.cc
90 Error.cc
91 FontEncodingTables.cc
92 Form.cc
93 Function.cc
94 Gfx.cc
95 GfxFont.cc
96 GfxState.cc
97 GlobalParams.cc
98 JArithmeticDecoder.cc
99 JBIG2Stream.cc
100 JPXStream.cc
101 Lexer.cc
102 Link.cc
103 NameToCharCode.cc
104 Object.cc
105 OptionalContent.cc
106 Outline.cc
107 OutputDev.cc
108 Page.cc
109 Parser.cc
110 PDFDoc.cc
111 PDFDocEncoding.cc
112 PSTokenizer.cc
113 SecurityHandler.cc
114 Stream.cc
115 TextString.cc
116 UnicodeMap.cc
117 UnicodeTypeTable.cc
118 UTF8.cc
119 XFAForm.cc
120 XRef.cc
121 Zoox.cc
122)
123
124#--- object files needed by XpdfWidget
125
126if ((QT4_FOUND OR Qt5Widgets_FOUND)
127 AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
128
129 if (HIGHLIGHTED_REGIONS)
130 set(HIGHLIGHT_SRC "HighlightFile.cc")
131 else ()
132 set(HIGHLIGHT_SRC "")
133 endif ()
134
135 add_library(xpdf_widget_objs OBJECT
136 DisplayState.cc
137 PDFCore.cc
138 PreScanOutputDev.cc
139 PSOutputDev.cc
140 SplashOutputDev.cc
141 TextOutputDev.cc
142 TileCache.cc
143 TileCompositor.cc
144 TileMap.cc
145 ${HIGHLIGHT_SRC}
146 )
147endif ()
148
149#--- pdftops
150
151if (HAVE_SPLASH)
152 add_executable(pdftops
153 $<TARGET_OBJECTS:xpdf_objs>
154 PreScanOutputDev.cc
155 PSOutputDev.cc
156 SplashOutputDev.cc
157 pdftops.cc
158 )
159 if(GSDLFLAG_STATIC)
160 target_link_libraries(pdftops goo fofi splash
161 ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -ltiff -ljpeg -lz -lm -lc -lpthread)
162 # Threads::Threads instead of -lpthread results in a partially dynamic executable
163 else ()
164 target_link_libraries(pdftops goo fofi splash
165 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
166 ${DTYPE_LIBRARY}
167 ${LCMS_LIBRARY}
168 ${TIFF_LIBRARY} ${JPEG_LIBRARY}
169 ${ZLIB_LIBRARIES})
170 endif ()
171else ()
172 add_executable(pdftops
173 $<TARGET_OBJECTS:xpdf_objs>
174 PreScanOutputDev.cc
175 PSOutputDev.cc
176 pdftops.cc
177 )
178 if(GSDLFLAG_STATIC)
179 target_link_libraries(pdftops goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lm -lc -lpthread)
180 else ()
181 target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY})
182 endif ()
183endif ()
184install(TARGETS pdftops RUNTIME DESTINATION bin)
185install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
186
187#--- pdftotext
188
189add_executable(pdftotext
190 $<TARGET_OBJECTS:xpdf_objs>
191 TextOutputDev.cc
192 pdftotext.cc
193)
194if(GSDLFLAG_STATIC)
195 target_link_libraries(pdftotext goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread)
196 # Threads::Threads instead of -lpthread results in a partially dynamic executable
197else ()
198 target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY})
199endif ()
200install(TARGETS pdftotext RUNTIME DESTINATION bin)
201install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
202
203#--- pdftohtml
204
205if (HAVE_SPLASH AND PNG_FOUND)
206 add_executable(pdftohtml
207 $<TARGET_OBJECTS:xpdf_objs>
208 HTMLGen.cc
209 SplashOutputDev.cc
210 TextOutputDev.cc
211 pdftohtml.cc
212 )
213 if(GSDLFLAG_STATIC)
214 target_link_libraries(pdftohtml goo fofi splash
215 ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -ltiff -ljpeg -lpng -lz -lm -lc -lpthread)
216 else ()
217 target_link_libraries(pdftohtml goo fofi splash
218 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
219 ${DTYPE_LIBRARY}
220 ${LCMS_LIBRARY}
221 ${TIFF_LIBRARY} ${JPEG_LIBRARY}
222 ${PNG_LIBRARIES})
223 endif ()
224 install(TARGETS pdftohtml RUNTIME DESTINATION bin)
225 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
226endif ()
227
228#--- pdfinfo
229
230add_executable(pdfinfo
231 $<TARGET_OBJECTS:xpdf_objs>
232 pdfinfo.cc
233)
234if(GSDLFLAG_STATIC)
235 target_link_libraries(pdfinfo goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread)
236else ()
237 target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY})
238endif()
239install(TARGETS pdfinfo RUNTIME DESTINATION bin)
240install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
241
242#--- pdffonts
243
244add_executable(pdffonts
245 $<TARGET_OBJECTS:xpdf_objs>
246 pdffonts.cc
247)
248if(GSDLFLAG_STATIC)
249 target_link_libraries(pdffonts goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread)
250else ()
251 target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY})
252endif ()
253install(TARGETS pdffonts RUNTIME DESTINATION bin)
254install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
255
256#--- pdfdetach
257
258add_executable(pdfdetach
259 $<TARGET_OBJECTS:xpdf_objs>
260 pdfdetach.cc
261)
262if(GSDLFLAG_STATIC)
263 target_link_libraries(pdfdetach goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread)
264else ()
265 target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY})
266endif ()
267install(TARGETS pdfdetach RUNTIME DESTINATION bin)
268install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
269
270#--- pdftoppm
271
272if (HAVE_SPLASH)
273 add_executable(pdftoppm
274 $<TARGET_OBJECTS:xpdf_objs>
275 SplashOutputDev.cc
276 pdftoppm.cc
277 )
278 if(GSDLFLAG_STATIC)
279 target_link_libraries(pdftoppm goo fofi splash
280 ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -ltiff -ljpeg -lz -lm -lc -lpthread)
281 else ()
282 target_link_libraries(pdftoppm goo fofi splash
283 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
284 ${DTYPE_LIBRARY}
285 ${LCMS_LIBRARY}
286 ${TIFF_LIBRARY} ${JPEG_LIBRARY}
287 ${ZLIB_LIBRARIES})
288 endif ()
289 install(TARGETS pdftoppm RUNTIME DESTINATION bin)
290 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
291endif ()
292
293#--- pdftopng
294
295if (HAVE_SPLASH AND PNG_FOUND)
296 add_executable(pdftopng
297 $<TARGET_OBJECTS:xpdf_objs>
298 SplashOutputDev.cc
299 pdftopng.cc
300 )
301 if(GSDLFLAG_STATIC)
302 target_link_libraries(pdftopng goo fofi splash
303 ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -ltiff -ljpeg -lpng -lz -lm -lc -lpthread)
304 else ()
305 target_link_libraries(pdftopng goo fofi splash
306 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
307 ${DTYPE_LIBRARY}
308 ${TIFF_LIBRARY} ${JPEG_LIBRARY}
309 ${LCMS_LIBRARY} ${PNG_LIBRARIES})
310 endif ()
311 install(TARGETS pdftopng RUNTIME DESTINATION bin)
312 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
313endif ()
314
315#--- pdfimages
316
317add_executable(pdfimages
318 $<TARGET_OBJECTS:xpdf_objs>
319 ImageOutputDev.cc
320 pdfimages.cc
321)
322if(GSDLFLAG_STATIC)
323 target_link_libraries(pdfimages goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread)
324else ()
325 target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY})
326endif ()
327install(TARGETS pdfimages RUNTIME DESTINATION bin)
328install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
329
330#--- xpdfrc man page
331
332install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
Note: See TracBrowser for help on using the repository browser.