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

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

Finally, committing the version of the code that runs the static compilation of xpdf-tools to completion. Still have the issue that pdftohtml and possibly some other binaries don't run (bash says it can't find the file when I try to execute pdftohtml), but pdftotext at least runs to print the usage, though I have yet to test that out on an actual PDF. Committing this version since it at least completes the process of building xpdf-tools statically. The CMakeLists.txt file introduced in this commit (and now contained in the current update to gs-xpdf-4.00.tar.gz) contains all the modifications made to the original CMakeLists.txt (the one in xpdf-4.00.tar.gz).

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