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

Last change on this file since 32248 was 32248, checked in by ak19, 6 years ago
  1. Overhaul to the GS-README for the xpdf-tools extension. 2. Moved a lot of verbose comments that explain reasonings behind doing things from gs-CMakeLists.txt and somewhat from XPDFTOOLS.sh
File size: 10.0 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 (PNG_FOUND)
36 include_directories("${PNG_INCLUDE_DIRS}")
37 add_definitions("${PNG_DEFINITIONS}")
38else ()
39 message(STATUS "@@@@@@@@@@@@@@@ NO PNG_FOUND")
40endif ()
41# https://stackoverflow.com/questions/36126333/mingw-cmake-undefined-reference-to-zlib
42if (ZLIB_FOUND)
43 include_directories("${ZLIB_INCLUDE_DIRS}")
44 add_definitions("${ZLIB_DEFINITIONS}")
45else ()
46 message(STATUS "@@@@@@@@@@@@@@@ NO ZLIB_FOUND")
47endif ()
48if (HAVE_LCMS)
49 include_directories("${LCMS_INCLUDE_DIR}")
50 set(COLOR_MANAGER_SOURCE "ColorManager.cc")
51 if(GSDLFLAG_STATIC)
52 # Untested combination, warn https://cmake.org/cmake/help/v3.0/command/message.html
53 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. @@@@@@@@@@@@@@@")
54 endif ()
55else ()
56 set(COLOR_MANAGER_SOURCE "")
57endif ()
58if (DTYPE_LIBRARY)
59 if(GSDLFLAG_STATIC)
60 # Untested combination, warn
61 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. @@@@@@@@@@@@@@@")
62 endif ()
63endif ()
64add_library(xpdf_objs OBJECT
65 AcroForm.cc
66 Annot.cc
67 Array.cc
68 BuiltinFont.cc
69 BuiltinFontTables.cc
70 Catalog.cc
71 CharCodeToUnicode.cc
72 CMap.cc
73 ${COLOR_MANAGER_SOURCE}
74 Decrypt.cc
75 Dict.cc
76 Error.cc
77 FontEncodingTables.cc
78 Form.cc
79 Function.cc
80 Gfx.cc
81 GfxFont.cc
82 GfxState.cc
83 GlobalParams.cc
84 JArithmeticDecoder.cc
85 JBIG2Stream.cc
86 JPXStream.cc
87 Lexer.cc
88 Link.cc
89 NameToCharCode.cc
90 Object.cc
91 OptionalContent.cc
92 Outline.cc
93 OutputDev.cc
94 Page.cc
95 Parser.cc
96 PDFDoc.cc
97 PDFDocEncoding.cc
98 PSTokenizer.cc
99 SecurityHandler.cc
100 Stream.cc
101 TextString.cc
102 UnicodeMap.cc
103 UnicodeTypeTable.cc
104 UTF8.cc
105 XFAForm.cc
106 XRef.cc
107 Zoox.cc
108)
109
110#--- object files needed by XpdfWidget
111
112if ((QT4_FOUND OR Qt5Widgets_FOUND)
113 AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
114
115 if (HIGHLIGHTED_REGIONS)
116 set(HIGHLIGHT_SRC "HighlightFile.cc")
117 else ()
118 set(HIGHLIGHT_SRC "")
119 endif ()
120
121 add_library(xpdf_widget_objs OBJECT
122 DisplayState.cc
123 PDFCore.cc
124 PreScanOutputDev.cc
125 PSOutputDev.cc
126 SplashOutputDev.cc
127 TextOutputDev.cc
128 TileCache.cc
129 TileCompositor.cc
130 TileMap.cc
131 ${HIGHLIGHT_SRC}
132 )
133endif ()
134
135#--- pdftops
136
137if (HAVE_SPLASH)
138 add_executable(pdftops
139 $<TARGET_OBJECTS:xpdf_objs>
140 PreScanOutputDev.cc
141 PSOutputDev.cc
142 SplashOutputDev.cc
143 pdftops.cc
144 )
145 if(GSDLFLAG_STATIC)
146 target_link_libraries(pdftops goo fofi splash
147 ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lz -lm -lc -lpthread)
148 # Threads::Threads instead of -lpthread results in a partially dynamic executable
149 else ()
150 target_link_libraries(pdftops goo fofi splash
151 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
152 ${DTYPE_LIBRARY}
153 ${LCMS_LIBRARY}
154 ${ZLIB_LIBRARIES})
155 endif ()
156else ()
157 add_executable(pdftops
158 $<TARGET_OBJECTS:xpdf_objs>
159 PreScanOutputDev.cc
160 PSOutputDev.cc
161 pdftops.cc
162 )
163 if(GSDLFLAG_STATIC)
164 target_link_libraries(pdftops goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -lm -lc -lpthread)
165 else ()
166 target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY})
167 endif ()
168endif ()
169install(TARGETS pdftops RUNTIME DESTINATION bin)
170install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
171
172#--- pdftotext
173
174add_executable(pdftotext
175 $<TARGET_OBJECTS:xpdf_objs>
176 TextOutputDev.cc
177 pdftotext.cc
178)
179if(GSDLFLAG_STATIC)
180 target_link_libraries(pdftotext goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -lpthread)
181 # Threads::Threads instead of -lpthread results in a partially dynamic executable
182else ()
183 target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY})
184endif ()
185install(TARGETS pdftotext RUNTIME DESTINATION bin)
186install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
187
188#--- pdftohtml
189
190if (HAVE_SPLASH AND PNG_FOUND)
191 add_executable(pdftohtml
192 $<TARGET_OBJECTS:xpdf_objs>
193 HTMLGen.cc
194 SplashOutputDev.cc
195 TextOutputDev.cc
196 pdftohtml.cc
197 )
198 if(GSDLFLAG_STATIC)
199 target_link_libraries(pdftohtml goo fofi splash
200 ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lpng -lz -lm -lc -lpthread)
201 else ()
202 target_link_libraries(pdftohtml goo fofi splash
203 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
204 ${DTYPE_LIBRARY}
205 ${LCMS_LIBRARY} ${PNG_LIBRARIES})
206 endif ()
207 install(TARGETS pdftohtml RUNTIME DESTINATION bin)
208 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
209endif ()
210
211#--- pdfinfo
212
213add_executable(pdfinfo
214 $<TARGET_OBJECTS:xpdf_objs>
215 pdfinfo.cc
216)
217if(GSDLFLAG_STATIC)
218 target_link_libraries(pdfinfo goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -lpthread)
219else ()
220 target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY})
221endif()
222install(TARGETS pdfinfo RUNTIME DESTINATION bin)
223install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
224
225#--- pdffonts
226
227add_executable(pdffonts
228 $<TARGET_OBJECTS:xpdf_objs>
229 pdffonts.cc
230)
231if(GSDLFLAG_STATIC)
232 target_link_libraries(pdffonts goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -lpthread)
233else ()
234 target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY})
235endif ()
236install(TARGETS pdffonts RUNTIME DESTINATION bin)
237install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
238
239#--- pdfdetach
240
241add_executable(pdfdetach
242 $<TARGET_OBJECTS:xpdf_objs>
243 pdfdetach.cc
244)
245if(GSDLFLAG_STATIC)
246 target_link_libraries(pdfdetach goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -lpthread)
247else ()
248 target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY})
249endif ()
250install(TARGETS pdfdetach RUNTIME DESTINATION bin)
251install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
252
253#--- pdftoppm
254
255if (HAVE_SPLASH)
256 add_executable(pdftoppm
257 $<TARGET_OBJECTS:xpdf_objs>
258 SplashOutputDev.cc
259 pdftoppm.cc
260 )
261 if(GSDLFLAG_STATIC)
262 target_link_libraries(pdftoppm goo fofi splash
263 ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lz -lm -lc -lpthread)
264 else ()
265 target_link_libraries(pdftoppm goo fofi splash
266 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
267 ${DTYPE_LIBRARY}
268 ${LCMS_LIBRARY}
269 ${ZLIB_LIBRARIES})
270 endif ()
271 install(TARGETS pdftoppm RUNTIME DESTINATION bin)
272 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
273endif ()
274
275#--- pdftopng
276
277if (HAVE_SPLASH AND PNG_FOUND)
278 add_executable(pdftopng
279 $<TARGET_OBJECTS:xpdf_objs>
280 SplashOutputDev.cc
281 pdftopng.cc
282 )
283 if(GSDLFLAG_STATIC)
284 target_link_libraries(pdftopng goo fofi splash
285 ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lpng -lz -lm -lc -lpthread)
286 else ()
287 target_link_libraries(pdftopng goo fofi splash
288 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
289 ${DTYPE_LIBRARY}
290 ${LCMS_LIBRARY} ${PNG_LIBRARIES})
291 endif ()
292 install(TARGETS pdftopng RUNTIME DESTINATION bin)
293 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
294endif ()
295
296#--- pdfimages
297
298add_executable(pdfimages
299 $<TARGET_OBJECTS:xpdf_objs>
300 ImageOutputDev.cc
301 pdfimages.cc
302)
303if(GSDLFLAG_STATIC)
304 target_link_libraries(pdfimages goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -lpthread)
305else ()
306 target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY})
307endif ()
308install(TARGETS pdfimages RUNTIME DESTINATION bin)
309install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
310
311#--- xpdfrc man page
312
313install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
Note: See TracBrowser for help on using the repository browser.