source: gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt_complicated@ 32228

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

Tried to compile xpdf-tools up statically with CMake, but still not successful. For now committing modifications necessary (including the new additional packages) for compiling xpdf-tools agains dynamically linked libs of libpng and zlib and freetype. Although these 3 packages have been introduced and are successfully compiled up (and I can even get the CMake configure stage of xpdf-tools to 'see' them), the xpdftools binaries upon successful compilation are shown by ldd to still refer to system versions of zlib, libpng and freetype. Some modifications to a single file in the xpdftools src package were necessary to get things to compile again with these changes, so recommitting the xpdftools src package with modications using the usual gs- prefix and a readme.

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