root/gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt @ 32234

Revision 32234, 7.3 KB (checked in by ak19, 2 years ago)

Introducing gs-CMakeLists.txt as a GS customised CMakeLists.txt to replace the one in the xpdf tools src code package once the latter's been untarred. XPDFTools.sh takes care of doing the replacement after the untar operation. Minor cleanup to CMAKE.sh

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.
13# Customised for Greenstone.
14#========================================================================
15
16include_directories("${PROJECT_SOURCE_DIR}")
17include_directories("${PROJECT_BINARY_DIR}")
18include_directories("${PROJECT_SOURCE_DIR}/goo")
19include_directories("${PROJECT_SOURCE_DIR}/fofi")
20include_directories("${PROJECT_SOURCE_DIR}/splash")
21if (PNG_FOUND)
22  include_directories("${PNG_INCLUDE_DIRS}")
23  add_definitions("${PNG_DEFINITIONS}")
24else ()
25  message(STATUS "@@@@@@@@@@@@@@@ NO PNG_FOUND")
26endif ()
27# https://stackoverflow.com/questions/36126333/mingw-cmake-undefined-reference-to-zlib
28if (ZLIB_FOUND)
29  include_directories("${ZLIB_INCLUDE_DIRS}")
30  add_definitions("${ZLIB_DEFINITIONS}")
31else ()
32  message(STATUS "@@@@@@@@@@@@@@@ NO ZLIB_FOUND")
33endif ()
34if (HAVE_LCMS)
35  include_directories("${LCMS_INCLUDE_DIR}")
36  set(COLOR_MANAGER_SOURCE "ColorManager.cc")
37else ()
38  set(COLOR_MANAGER_SOURCE "")
39endif ()
40
41add_library(xpdf_objs OBJECT
42  AcroForm.cc
43  Annot.cc
44  Array.cc
45  BuiltinFont.cc
46  BuiltinFontTables.cc
47  Catalog.cc
48  CharCodeToUnicode.cc
49  CMap.cc
50  ${COLOR_MANAGER_SOURCE}
51  Decrypt.cc
52  Dict.cc
53  Error.cc
54  FontEncodingTables.cc
55  Form.cc
56  Function.cc
57  Gfx.cc
58  GfxFont.cc
59  GfxState.cc
60  GlobalParams.cc
61  JArithmeticDecoder.cc
62  JBIG2Stream.cc
63  JPXStream.cc
64  Lexer.cc
65  Link.cc
66  NameToCharCode.cc
67  Object.cc
68  OptionalContent.cc
69  Outline.cc
70  OutputDev.cc
71  Page.cc
72  Parser.cc
73  PDFDoc.cc
74  PDFDocEncoding.cc
75  PSTokenizer.cc
76  SecurityHandler.cc
77  Stream.cc
78  TextString.cc
79  UnicodeMap.cc
80  UnicodeTypeTable.cc
81  UTF8.cc
82  XFAForm.cc
83  XRef.cc
84  Zoox.cc
85)
86
87#--- object files needed by XpdfWidget
88
89if ((QT4_FOUND OR Qt5Widgets_FOUND)
90    AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
91
92  if (HIGHLIGHTED_REGIONS)
93    set(HIGHLIGHT_SRC "HighlightFile.cc")
94  else ()
95    set(HIGHLIGHT_SRC "")
96  endif ()
97
98  add_library(xpdf_widget_objs OBJECT
99    DisplayState.cc
100    PDFCore.cc
101    PreScanOutputDev.cc
102    PSOutputDev.cc
103    SplashOutputDev.cc
104    TextOutputDev.cc
105    TileCache.cc
106    TileCompositor.cc
107    TileMap.cc
108    ${HIGHLIGHT_SRC}
109  )
110endif ()
111
112# We want to build static xpdf-tools binaries. See
113# https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake
114# Want to make the min number of changes for building statically, so using the way
115# below. Beware, must *append* "-static" to existing CMAKE_EXE_LINKER_FLAGS=LD_FLAGS
116SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
117SET(BUILD_SHARED_LIBS OFF)
118SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
119
120# The original, unmodified CMakeLists.txt was not set up sufficiently
121# for static compilation of xpdf-tools. As a result, compile would first fail
122# with errors about undefined refs to mutex / lpthread.
123# When building xpdf-tools statically, need to add the following 2 lines as well
124# as append "Threads::Threads" to the end of each "target_link_libraries(<list>)"
125# See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
126# found googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:
127#   undefined reference to `pthread_mutex_unlock'
128set(THREADS_PREFER_PTHREAD_FLAG ON)
129find_package(Threads REQUIRED)
130
131#--- pdftops
132
133if (HAVE_SPLASH)
134  add_executable(pdftops
135    $<TARGET_OBJECTS:xpdf_objs>
136    PreScanOutputDev.cc
137    PSOutputDev.cc
138    SplashOutputDev.cc
139    pdftops.cc
140  )
141  target_link_libraries(pdftops goo fofi splash
142                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
143            ${ZLIB_LIBRARIES}
144                        ${DTYPE_LIBRARY}
145                        ${LCMS_LIBRARY}
146            Threads::Threads)
147else ()
148  add_executable(pdftops
149    $<TARGET_OBJECTS:xpdf_objs>
150    PreScanOutputDev.cc
151    PSOutputDev.cc
152    pdftops.cc
153  )
154  target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} Threads::Threads)
155endif ()
156install(TARGETS pdftops RUNTIME DESTINATION bin)
157install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
158
159#--- pdftotext
160
161add_executable(pdftotext
162  $<TARGET_OBJECTS:xpdf_objs>
163  TextOutputDev.cc
164  pdftotext.cc
165)
166target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} Threads::Threads)
167install(TARGETS pdftotext RUNTIME DESTINATION bin)
168install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
169
170#--- pdftohtml
171
172if (HAVE_SPLASH AND PNG_FOUND)
173  add_executable(pdftohtml
174    $<TARGET_OBJECTS:xpdf_objs>
175    HTMLGen.cc
176    SplashOutputDev.cc
177    TextOutputDev.cc
178    pdftohtml.cc
179  )
180  target_link_libraries(pdftohtml goo fofi splash
181                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
182                        ${DTYPE_LIBRARY}
183                        ${LCMS_LIBRARY} ${PNG_LIBRARIES}
184            Threads::Threads)
185  install(TARGETS pdftohtml RUNTIME DESTINATION bin)
186  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
187endif ()
188
189#--- pdfinfo
190
191add_executable(pdfinfo
192  $<TARGET_OBJECTS:xpdf_objs>
193  pdfinfo.cc
194)
195target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} Threads::Threads)
196install(TARGETS pdfinfo RUNTIME DESTINATION bin)
197install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
198
199#--- pdffonts
200
201add_executable(pdffonts
202  $<TARGET_OBJECTS:xpdf_objs>
203  pdffonts.cc
204)
205target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} Threads::Threads)
206install(TARGETS pdffonts RUNTIME DESTINATION bin)
207install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
208
209#--- pdfdetach
210
211add_executable(pdfdetach
212  $<TARGET_OBJECTS:xpdf_objs>
213  pdfdetach.cc
214)
215target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} Threads::Threads)
216install(TARGETS pdfdetach RUNTIME DESTINATION bin)
217install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
218
219#--- pdftoppm
220
221if (HAVE_SPLASH)
222  add_executable(pdftoppm
223    $<TARGET_OBJECTS:xpdf_objs>
224    SplashOutputDev.cc
225    pdftoppm.cc
226  )
227  target_link_libraries(pdftoppm goo fofi splash
228                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
229            ${ZLIB_LIBRARIES}
230                        ${DTYPE_LIBRARY}
231                        ${LCMS_LIBRARY}
232            Threads::Threads)
233  install(TARGETS pdftoppm RUNTIME DESTINATION bin)
234  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
235endif ()
236
237#--- pdftopng
238
239if (HAVE_SPLASH AND PNG_FOUND)
240  add_executable(pdftopng
241    $<TARGET_OBJECTS:xpdf_objs>
242    SplashOutputDev.cc
243    pdftopng.cc
244  )
245  target_link_libraries(pdftopng goo fofi splash
246                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
247                        ${DTYPE_LIBRARY}
248                        ${LCMS_LIBRARY} ${PNG_LIBRARIES}
249            Threads::Threads)
250  install(TARGETS pdftopng RUNTIME DESTINATION bin)
251  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
252endif ()
253
254#--- pdfimages
255
256add_executable(pdfimages
257  $<TARGET_OBJECTS:xpdf_objs>
258  ImageOutputDev.cc
259  pdfimages.cc
260)
261target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} Threads::Threads)
262install(TARGETS pdfimages RUNTIME DESTINATION bin)
263install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
264
265#--- xpdfrc man page
266
267install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
Note: See TracBrowser for help on using the browser.