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

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